1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#include<iostream>
using namespace std;
void getRain(double[], int);
void dualSort(int[], double[], int);
void showOrder(int[], char[][20], double[], int);
int main()
{
const int SIZE = 12; //size of array
double rain[SIZE];
const int NUM_MONTHS = 12;
int month[NUM_MONTHS] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
char month_name[NUM_MONTHS][20]=
{
"January","February","March", "April","May",
"June","July","August","September","October",
"November","December"
};
getRain(rain, SIZE);
dualSort(month, rain, SIZE);
showOrder(month, month_name, rain, SIZE);
system("pause");
return 0;
}
void getRain(double rain[], int SIZE) {/*...*/}
void dualSort(int month[], double rain[], int size) {/*...*/}
void showOrder(int month[], char month_name[][20], double rain[], int num)
{
cout << "\n\tMonth\t\t Rainfall\n";
cout << "\t--------------------------\n";
for(int index = 0; index < num; index++)
{
cout << "\t" << month_name[month[index]-1] << "\t\t";
cout << "\t" << rain[index] << endl;
}
cout << endl;
}
|