Merge pull request 'void' (#6) from ph6m83j2r/text4:void into 计算每个学生各门课程的总分和平均分
commit
b4f33e0984
@ -1,16 +1,14 @@
|
|||||||
// 函数功能:计算每个学生各门课程的总分和平均分
|
// 函数功能:输入n个学生的m门课成绩
|
||||||
void AverSumofEveryStudent(STU stu[], int n, int m)
|
void ReadScore(STU stu[], int n, int m)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
for (i=0; i<n; i++)
|
printf("Input student's ID, name and score:\n");
|
||||||
{
|
/* ---------- begain ---------- */
|
||||||
stu[i].sum = 0;
|
for(i=0;i<n;i++)
|
||||||
for (j=0; j<m; j++)
|
{scanf("%ld%s",&stu[i].num,stu[i].name);
|
||||||
{
|
for (j=0; j<m; j++)
|
||||||
stu[i].sum = stu[i].sum + stu[i].score[j];
|
scanf("%f",&stu[i].score[j]);
|
||||||
}
|
}
|
||||||
stu[i].aver = m>0 ? stu[i].sum / m : -1;
|
|
||||||
printf("student %d: sum = %.0f, aver = %.0f\n",
|
/* ----------- end ----------- */
|
||||||
i+1, stu[i].sum, stu[i].aver);
|
}
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue