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
|
#include <iostream>
using namespace std;
static const int COLS=7;
static const int ROWS=60;
typedef int all_students_grades_t[ROWS][COLS];
int average_grade(all_students_grades_t grades,int student)
{
float sum=0;
for (int i=0; i<COLS; i++)
{
sum+=grades[student][i];
}
return (sum/COLS)+0.5;
}
int main()
{
all_students_grades_t all_grades=
{
{ 90, 97, 85, 12, 99, 79, 82 }, // this student paid attention
{ 19, 4, 23, 88, 47, 0, 26 }, // this student did not
{ 0 } // there are no more students
};
cout<<"Good student's grade is "<<average_grade(all_grades,0)<<endl;
cout<<"Lazy student's grade is "<<average_grade(all_grades,1)<<endl;
return 0;
}
|