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 47 48 49 50
|
#include <iostream>
#include <string>
using namespace std;
//fp
void compare(int [], int [], int [], int []);
void show(int [], int [], string []);
int main()
{
//declare and initialization
const int month = 12;
string month_name[month] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
int tempe1[month] = {12,85,36,15,99,62,19,62,43,22,71,66};
int tempe2[month] = {55,25,67,80,21,14,42,83,24,60,94,56};
int tempeh[month], tempel[month];
compare(tempe1, tempe2, tempeh, tempel);
show(tempeh, tempel, month_name);
cin.get();
cin.get();
}
void compare(int t1 [], int t2 [], int h [], int l [])
{
for (int i = 0; i < 12; ++i)
{
if (t1[i] > t2[i])
{
h[i] = t1[i];
l[i] = t2[i];
}
else
{
h[i] = t2[i];
l[i] = t1[i];
}
}
}
void show(int th[], int tl[], string n[])
{
for (int i = 0; i < 12; ++i)
{
cout << "[" << n[i] << "] High : " << th[i] << ". Low : " << tl[i] << "." << endl;
}
}
|