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
|
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
double average;
int min = -1;
int maximum;
int exams[5][4] = { { 50, 86, 75, 78 },
{ 68, 76, 82, 0 },
{ 74, 65, 80, 90 },
{ 80, 79, 86, 92 },
{ 45, 50, 77, 82 } };
for (int col = 0; col < 4; col++)
{
for (int row = 0; row < 5; row++)
{
average = average + exams[row][col];
if (min < 0)
{
min = exams[row][col];
maximum = min;
}
if (min >= exams[row][col])
{
min = exams[row][col];
}
if (maximum < exams[row][col])
{
maximum = exams[row][col];
}
}
average = average / 5;
cout << " \n Exam:" << col + 1 << endl;
cout << " Average: " << average << endl;
cout << " Min: " << min << endl;
cout << " Max: " << maximum << endl;
min = 200;
average = 0;
}
system("pause");
return 0;
}
|