|
|
|
@ -153,7 +153,25 @@ int main(void)
|
|
|
|
|
```
|
|
|
|
|
int Menu(void)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
int itemSelected;
|
|
|
|
|
printf("Management for Students' scores\n");
|
|
|
|
|
printf("1.Input record\n");
|
|
|
|
|
printf("2.Calculate total and average score of every course\n");
|
|
|
|
|
printf("3.Calculate total and average score of evry student\n");
|
|
|
|
|
printf("4.Sort in descending order by score\n");
|
|
|
|
|
printf("5.Sort in ascending order by score\n");
|
|
|
|
|
printf("6.Sort in ascending order by number\n");
|
|
|
|
|
printf("7.Sort in dictionary order by name\n");
|
|
|
|
|
printf("8.Search by number\n");
|
|
|
|
|
printf("9.Search by name\n");
|
|
|
|
|
printf("10.Statistic analysis\n");
|
|
|
|
|
printf("11.List record\n");
|
|
|
|
|
printf("12.Write to a file\n");
|
|
|
|
|
printf("13.Read from a file\n");
|
|
|
|
|
printf("0.Exit\n");
|
|
|
|
|
printf("Please Input your choice:");
|
|
|
|
|
scanf("%d",&itemSelected); //读入用户输入
|
|
|
|
|
return itemSelected;
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
@ -169,7 +187,17 @@ void ReadScore(STU stu[],int n,int m)
|
|
|
|
|
```
|
|
|
|
|
void AverSumofEveryStudent(STU stu[],int n,int m)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
int i,j;
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
stu[i].sum = 0; //初始化每个学生总分为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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
@ -177,8 +205,22 @@ void AverSumofEveryStudent(STU stu[],int n,int m)
|
|
|
|
|
```
|
|
|
|
|
void AverSumofEveryCourse(STU stu[],int n,int m)
|
|
|
|
|
{
|
|
|
|
|
int i,j;
|
|
|
|
|
float sum[COURSE_NUM],aver[COURSE_NUM];
|
|
|
|
|
/*--------------begin------------*/
|
|
|
|
|
for(j=0;j<m;j++)
|
|
|
|
|
{
|
|
|
|
|
sum[j] = 0;
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
sum[j]+= stu[i].score[j]; //计算n个同学每门课程的总分
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
aver[j] = sum[j]/i;
|
|
|
|
|
printf("student %d: sum = %.0f,aver = %.0f\n",j+1, sum[j], aver[j]);
|
|
|
|
|
}
|
|
|
|
|
/*--------------------end------------------------*/
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
//函数功能:按选择法将数组 sum 的元素值排序
|
|
|
|
|