From 46a7b8169fb3bfdb1f260df165ae34951fe41a8e Mon Sep 17 00:00:00 2001 From: Cx330 <2011690092@qq.com> Date: Fri, 14 Apr 2023 23:58:03 +0800 Subject: [PATCH] Cx330_3 --- README.md | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7762331..e6fa115 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,36 @@ void PrintScore(STU stu[],int n,int m); //打印学生成绩的函 void WritetoFile(STU record[],int n,int m); //输出学生信息到文件中的函数 void ReadfromFile(STU record[],int *n,int *m); //从文件中读取学生信息的函数 ``` -### 成绩录入 + +#### 主函数 +``` +int main(void) +{ + char ch; + int n = 0,m = 0; + STU stu[STU_NUM]; + printf("Input student number(n<%d):",STU_NUM); + scnaf("%d",&n); + printf("Input course number(m<=%d):",COURSE_NUM); + scanf("%d",&m); + while(1) + { + ch = Menu(); //显示菜单,并读取用户输入 + switch(ch) + { + case 1:ReadScore(stu,n,m); + break; + case 2:AverSumofEveryCourse(stu,n,m); + break; + case 3:AverSumofEveryStudent(stu,n,m); + break; + case 4:SortbyScore(stu,n,m,Ascending); + printf("\nSort in ascending order by score:\n"); + } + } +} +``` +#### 成绩录入 设计思想:成绩录入是对结构体中班级、姓名、学号和五门成绩的录入,同时加上对五门成绩平均成绩的计算。按照基本的录入,只需要scanf函数对数据输入,用printf函数进行汉字的打印即可。然后进行文件保存该组数据,最后判断是否继续录入。