Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5. void sortArray(double [], int, int[], int);
  6. void showArray(double [], int, int[], int);
  7. void showDate(int [], int);
  8.  
  9. int main()
  10.  
  11. {
  12. const int BASE = 7;
  13. const int DAY = 7;
  14. int sDate = 0;
  15. int eDate = 0;
  16. string month;
  17. double snowAmount[BASE];
  18. int showDay[DAY];
  19.  
  20. cout << "Please enter name of Month: ";
  21. cin >> month;
  22. cout << "Please enter the starting date of the seven day period: ";
  23. cin >> sDate;
  24. cout << "Please enter the ending date of the seven day period: ";
  25. cin >> eDate;
  26.  
  27. while (eDate != sDate +6)
  28. {
  29. cout << "Not a 7 day period." << endl;
  30. cout << "Please enter the starting date of the seven day period: ";
  31. cin >> sDate;
  32. cout << "Please enter the ending date of the seven day period: ";
  33. cin >> eDate;
  34. }
  35. cout << "Please enter the " << BASE << " base snow depths" << endl;
  36. cout << "Day " << sDate << ": ";
  37. cin >> snowAmount[0];
  38. cout << "Day " << sDate + 1 << ": ";
  39. cin >> snowAmount[1];
  40. cout << "Day " << sDate + 2 << ": ";
  41. cin >> snowAmount[2];
  42. cout << "Day " << sDate + 3 << ": ";
  43. cin >> snowAmount[3];
  44. cout << "Day " << sDate + 4 << ": ";
  45. cin >> snowAmount[4];
  46. cout << "Day " << sDate + 5 << ": ";
  47. cin >> snowAmount[5];
  48. cout << "Day " << sDate + 6 << ": ";
  49. cin >> snowAmount[6];
  50.  
  51. showDay[0] = sDate;
  52. showDay[1] = sDate + 1;
  53. showDay[2] = sDate + 2;
  54. showDay[3] = sDate + 3;
  55. showDay[4] = sDate + 4;
  56. showDay[5] = sDate + 5;
  57. showDay[6] = sDate + 6;
  58.  
  59. sortArray(snowAmount, BASE, showDay, DAY);
  60.  
  61. cout << endl;
  62. cout << "Snow Report " << month << " " << sDate << " - " << eDate << endl << endl;
  63.  
  64. showArray(snowAmount, BASE, showDay, DAY);
  65.  
  66. system ("PAUSE");
  67. return 0;
  68. }
  69. void sortArray(double array[], int size, int day[], int sizeDay)
  70. {
  71. double temp;
  72. bool swap;
  73. int temp2;
  74.  
  75. do
  76. { swap = false;
  77. for (int count = 0; count < size - 1; count ++)
  78. {
  79. if (array[count] > array [count + 1])
  80. {
  81. temp = array[count];
  82. temp2 = day[count];
  83. array[count] = array[count + 1];
  84. day[count] = day[count +1];
  85. array[count + 1] = temp;
  86. day[count + 1] = temp2;
  87. swap = true;
  88. }
  89. }
  90. } while(swap);
  91.  
  92. }
  93.  
  94. void showArray(double array[], int size, int day[], int sizeDay)
  95. {
  96. for (int count = 0; count < size; count++)
  97. cout << " Day: " << day[count] << " Base: " << array[count] << " " << endl;
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement