pull/3/head
parent
4ba7bfebc9
commit
839d14ae24
@ -1,16 +1,14 @@
|
||||
// 函数功能:计算每个学生各门课程的总分和平均分
|
||||
void AverSumofEveryStudent(STU stu[], int n, int m)
|
||||
// 函数功能:输入n个学生的m门课成绩
|
||||
void ReadScore(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);
|
||||
}
|
||||
int i, j;
|
||||
printf("Input student's ID, name and score:\n");
|
||||
/* ---------- begain ---------- */
|
||||
for(i=0;i<n;i++)
|
||||
{scanf("%ld%s",&stu[i].num,stu[i].name);
|
||||
for (j=0; j<m; j++)
|
||||
scanf("%f",&stu[i].score[j]);
|
||||
}
|
||||
|
||||
/* ----------- end ----------- */
|
||||
}
|
Loading…
Reference in new issue