diff --git a/file b/file index 0ea0602..f68282d 100644 --- a/file +++ b/file @@ -85,4 +85,76 @@ case 12:WritetoFile(stu, n, m); default:printf("Input error!"); } } - return 0;} \ No newline at end of file + return 0;} + // 函数功能:显示菜单并获得用户键盘输入的选项 +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 every 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; +} +// 函数功能:输入n个学生的m门课成绩 +void ReadScore(STU stu[], int n, int m) +{ + int i, j; + printf("Input student's ID, name and score:\n"); + /* ---------- begain ---------- */ + for(i=0;i0 ? stu[i].sum / m : -1; + printf("student %d: sum = %.0f, aver = %.0f\n", +i+1, stu[i].sum, stu[i].aver); + } +} +// 函数功能:计算每门课程的总分和平均分 +void AverSumofEveryCourse(STU stu[], int n, int m) +{ + int i, j; + float sum[COURSE_NUM], aver[COURSE_NUM]; + /* ---------- begain ---------- */ + for (j=0; j