From 7bfac75b0efdb5e5bfe9b8ed3f525f8a350d3c72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BF=9E=E6=A1=A2=E9=92=B0?= <2118998509@qq.com> Date: Sun, 21 May 2023 11:09:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E5=B9=B3=E5=9D=87=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- file | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) 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