Три группы студентов, в каждой из которых 20 человек, в сессию сдавали по 3 экзамена. Сведения об оценках каждой группы хранятся в двумерных мас- сивах. Определить лучшую по средней оценке группу.
#include <iostream>
#include <stdlib.h>
#include <cstdlib>
#include <ctime>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int i, j;
float x[20][3], y[20][3], z[20][3], nmax;
float c[2], max;
c[2] = { 0 };
for (i = 0; i<20; i++)
for (j = 0; j < 3; j++) {
x[i][j] = rand() % 5 + 1;
c[0] +=x[i][j];
y[i][j] = rand() % 5 + 1;
c[1] +=y[i][j];
z[i][j] = rand() % 5 + 1;
c[2] +=z[i][j];
}
for (i = 0; i<20; i++){
for (j = 0; j < 3; j++) {
cout<<x[i][j]<<"";
}
cout<<" ";
}
cout<<endl;
for (i = 0; i<20; i++){
for (j = 0; j < 3; j++) {
cout<<y[i][j]<<"";
}
cout<<" ";
}
cout<<endl;
for (i = 0; i<20; i++){
for (j = 0; j < 3; j++) {
cout<<z[i][j]<<"";
}
cout<<" ";
}
c[0] = c[0] / 60; c[1] = c[1] / 60; c[2] = c[2] / 60;
max = c[0]; nmax = 0;
for (i = 0; i<3; i++)
if (c[i]>max) { max = c[i]; nmax = i; }
cout << "\nLuchshaya sred osenka " << nmax + 1;
return 0;
}
