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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
/* Author: Brandon Duncan
Date: 08/28/2013
Purpose: Create an array that randomly generates a temperature for every hour of a week.
*/
#include <iostream>
#include <cmath>
#include <iomanip>
#include <ctime>
#include <cstdlib>
using namespace std;
int avg(int avg0,int avg1, int avg2, int avg3, int avg4, int avg5, int avg6)
{
int temp[7][24];
int a,total=0;
for(a=0;a<7;a++)
total = total + temp[0][a];
avg0 = (int) total/4;
return avg0;
for(a=0;a<7;a++)
total = total + temp[1][a];
avg1 = (int) total/4;
return avg1;
for(a=0;a<7;a++)
total = total + temp[2][a];
avg2 = (int) total/4;
return avg2;
for(a=0;a<7;a++)
total = total + temp[3][a];
avg3 = (int) total/4;
return avg3;
for(a=0;a<7;a++)
total = total + temp[4][a];
avg4 = (int) total/4;
return avg4;
for(a=0;a<7;a++)
total = total + temp[5][a];
avg5 = (int) total/4;
return avg5;
for(a=0;a<7;a++)
total = total + temp[6][a];
avg6 = (int) total/4;
return avg6;
}
int main()
{
int temp[7][24];
int average0,average1,average2,average3,average4,average5,average6;
srand((unsigned)time(NULL)); // This section is how the array is randomly generated.
for (int i = 1; i < 7; i++)
{
for (int j = 1; j < 24; j++)
{
temp[i][j] = 20+ rand() % 75;
}
}
avg(average0,average1,average2,average3,average4,average5,average6);
cout << "The average Noon tempature for this week is: " << average0 << endl;
system ("PAUSE");
return 0;
}
|