commit
a8fe51bac6
@ -0,0 +1,16 @@
|
||||
//2 函数功能:计算每个学生各门课程的总分和平均分
|
||||
void AverSumofEveryStudent(STU stu[], int n, int m)
|
||||
{
|
||||
int i, j;
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
stu[i].sum = 0;
|
||||
for (j=0; j<m; j++)
|
||||
{
|
||||
stu[i].sum = stu[i].sum + stu[i].score[j];
|
||||
}
|
||||
stu[i].aver = m>0 ? stu[i].sum / m : -1;
|
||||
printf("student %d: sum = %.0f, aver = %.0f\n",
|
||||
i+1, stu[i].sum, stu[i].aver);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue