Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- void sortArray(double [], int, int[], int);
- void showArray(double [], int, int[], int);
- void showDate(int [], int);
- int main()
- {
- const int BASE = 7;
- const int DAY = 7;
- int sDate = 0;
- int eDate = 0;
- string month;
- double snowAmount[BASE];
- int showDay[DAY];
- cout << "Please enter name of Month: ";
- cin >> month;
- cout << "Please enter the starting date of the seven day period: ";
- cin >> sDate;
- cout << "Please enter the ending date of the seven day period: ";
- cin >> eDate;
- while (eDate != sDate +6)
- {
- cout << "Not a 7 day period." << endl;
- cout << "Please enter the starting date of the seven day period: ";
- cin >> sDate;
- cout << "Please enter the ending date of the seven day period: ";
- cin >> eDate;
- }
- cout << "Please enter the " << BASE << " base snow depths" << endl;
- cout << "Day " << sDate << ": ";
- cin >> snowAmount[0];
- cout << "Day " << sDate + 1 << ": ";
- cin >> snowAmount[1];
- cout << "Day " << sDate + 2 << ": ";
- cin >> snowAmount[2];
- cout << "Day " << sDate + 3 << ": ";
- cin >> snowAmount[3];
- cout << "Day " << sDate + 4 << ": ";
- cin >> snowAmount[4];
- cout << "Day " << sDate + 5 << ": ";
- cin >> snowAmount[5];
- cout << "Day " << sDate + 6 << ": ";
- cin >> snowAmount[6];
- showDay[0] = sDate;
- showDay[1] = sDate + 1;
- showDay[2] = sDate + 2;
- showDay[3] = sDate + 3;
- showDay[4] = sDate + 4;
- showDay[5] = sDate + 5;
- showDay[6] = sDate + 6;
- sortArray(snowAmount, BASE, showDay, DAY);
- cout << endl;
- cout << "Snow Report " << month << " " << sDate << " - " << eDate << endl << endl;
- showArray(snowAmount, BASE, showDay, DAY);
- system ("PAUSE");
- return 0;
- }
- void sortArray(double array[], int size, int day[], int sizeDay)
- {
- double temp;
- bool swap;
- int temp2;
- do
- { swap = false;
- for (int count = 0; count < size - 1; count ++)
- {
- if (array[count] > array [count + 1])
- {
- temp = array[count];
- temp2 = day[count];
- array[count] = array[count + 1];
- day[count] = day[count +1];
- array[count + 1] = temp;
- day[count + 1] = temp2;
- swap = true;
- }
- }
- } while(swap);
- }
- void showArray(double array[], int size, int day[], int sizeDay)
- {
- for (int count = 0; count < size; count++)
- cout << " Day: " << day[count] << " Base: " << array[count] << " " << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement