|
|
@ -36,38 +36,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
分析系统的功能需求和界面需求,编制用户手册如下。
|
|
|
|
分析系统的功能需求和界面需求,编制用户手册如下。
|
|
|
|
|
|
|
|
|
|
|
|
### C1: 信息创建
|
|
|
|
### C1: 启动程序
|
|
|
|
|
|
|
|
|
|
|
|
创建学生基本信息,便于之后查询和浏览。利用结构体————定义STU结构体存储学生学号、姓名、各科成绩,总成绩和平均成绩,利用文件来存储,读取数据。
|
|
|
|
命令行中执行命令./app,系统启动,显示提示信息,然后显示功能菜单,等待用户输入命令。
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
typedef struct student{
|
|
|
|
Management for Students'scores
|
|
|
|
long num; //每个学生的学号
|
|
|
|
|
|
|
|
char name[MAX_LEN]; //每个学生的姓名
|
|
|
|
|
|
|
|
float score[COURSE_NUM]; //每个学生COURSE_NUM门功课的成绩
|
|
|
|
|
|
|
|
float sum; //每个学生的总成绩
|
|
|
|
|
|
|
|
float aver; //每个学生的平均成绩
|
|
|
|
|
|
|
|
}STU;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
1 Input record
|
|
|
|
|
|
|
|
2 Calculate total and average score of every course
|
|
|
|
### C2: 成绩录入
|
|
|
|
3 Calculate total and average score of every student
|
|
|
|
|
|
|
|
4 Sort in descending order by score
|
|
|
|
成绩录入时对结构体中班级、姓名、学号和五门成绩的录入,同时加上对五门成绩平均成绩的计算。按照基本的录入,只需用 scanf 函数对数据输入,用 printf 函数进行汉字的打印即可。然后进行文件保存该组数据,最后判断是否继续录入。
|
|
|
|
5 Sort in ascending order by score
|
|
|
|
|
|
|
|
6 Sort in ascending order by number
|
|
|
|
```
|
|
|
|
7 Sort in dictionary order by name
|
|
|
|
Input student number(n<%d):
|
|
|
|
8 Search by number
|
|
|
|
|
|
|
|
9 Search by name
|
|
|
|
|
|
|
|
10 Statistic analysis
|
|
|
|
|
|
|
|
11 List record
|
|
|
|
|
|
|
|
12 Write to a file
|
|
|
|
|
|
|
|
13 Read from a file
|
|
|
|
|
|
|
|
0 Exit
|
|
|
|
|
|
|
|
|
|
|
|
Input course number(m<=%d):
|
|
|
|
Please Input your choice:
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### C3:显示命令菜单
|
|
|
|
### C2: 显示命令菜单
|
|
|
|
|
|
|
|
|
|
|
|
显示菜单并获得用户键盘输入的选项
|
|
|
|
调用 Menu() 函数显示命令菜单,用户输入选项后,将结果返回主函数
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
Management for Students' scores
|
|
|
|
Management for Students'scores
|
|
|
|
|
|
|
|
|
|
|
|
1 Input record
|
|
|
|
1 Input record
|
|
|
|
2 Calculate total and average score of every course
|
|
|
|
2 Calculate total and average score of every course
|
|
|
|
3 Calculate total and average score of every student
|
|
|
|
3 Calculate total and average score of every student
|
|
|
@ -82,98 +83,271 @@ Management for Students' scores
|
|
|
|
12 Write to a file
|
|
|
|
12 Write to a file
|
|
|
|
13 Read from a file
|
|
|
|
13 Read from a file
|
|
|
|
0 Exit
|
|
|
|
0 Exit
|
|
|
|
Please Input your choice: //用户输入选项后将结果返回到主函数
|
|
|
|
|
|
|
|
|
|
|
|
Please Input your choice:
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
### C3: 计算每个学生各门课程的总分和平均分
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
选择菜单命令2,通过学号查找到该学生的结构体,通过结构体找到各科的成绩,然后进行求和和平均
|
|
|
|
### C3: 退出程序
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
选择菜单命令 0 ,再输入 y 确认,则退出程序。
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
stu[i].sum+=stu[i].score[j];//求和
|
|
|
|
Please Input your choice: 0
|
|
|
|
stu[i].aver=stu[i].sum/m;//求平均
|
|
|
|
Are you sure you want to exit?(Y/N): y
|
|
|
|
|
|
|
|
End of program!
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
### C4:计算每门课程的总分和平均分
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
选择菜单命令3,计算每门课程的总分和平均分,并将其按正确格式输出
|
|
|
|
### C4: 添加学生信息
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
选择菜单命令 1 ,假设n=4,m=3,提示输入学生的学号,姓名和成绩,然后利用循环逐个输入学生的学号和姓名以及各科成绩。
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
student n:sum = ,aver =
|
|
|
|
Please Input your choice: 1
|
|
|
|
|
|
|
|
Input student's ID, name and score:
|
|
|
|
|
|
|
|
2214111006 XuZilin 100 95 86
|
|
|
|
|
|
|
|
2214111009 XuZigui 77 89 99
|
|
|
|
|
|
|
|
2214111011 ZhangYu 85 91 98
|
|
|
|
|
|
|
|
2214111025 LiYujia 75 89 100
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### C5:按每个学生的总分由高到低排出名次表
|
|
|
|
### C5: 计算学生各门课程总分和平均分
|
|
|
|
|
|
|
|
|
|
|
|
选择菜单命令4,将结构体中的总分按降序排列,在此功能中需注意的是排序时要将整组数据随着总分一起改变,首先提示函数功能,然后输出每个同学各科成绩,总分,平均分,其间用Tab键分隔,并按总分高低逐个输出
|
|
|
|
选择菜单命令 2 ,计算学生各门课程总分和平均分,然后利用循环逐个输出学生的顺序,总成绩和平均分,结果都取整数。
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
Sort in descending order by score:
|
|
|
|
Please Input your choice: 2
|
|
|
|
|
|
|
|
student 1: sum = 281, aver = 93
|
|
|
|
|
|
|
|
student 2: sum = 265, aver = 88
|
|
|
|
|
|
|
|
student 3: sum = 274, aver = 91
|
|
|
|
|
|
|
|
student 4: sum = 264, aver = 88
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
### C6:按每个学生的总分由低到高排出名次表
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
选择菜单命令5,将结构体中的总分按升序排列,在此功能中需要注意的是将整组数据随着总分一起改变,首先提示函数功能是根据总分按升序排列,然后调用函数进行排序,最后输出每个同学各科成绩,总分,平均分,其间用Tab键分隔,并按总分低高逐个输出
|
|
|
|
### C6: 计算每门课程的总分和平均分
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
选择菜单命令 3 ,计算每门课程的总分和平均分,然后利用循环逐个输出每门课程的总分和平均分,结果都取整数。
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
Sort in ascending order by score:
|
|
|
|
Please Input your choice: 3
|
|
|
|
|
|
|
|
course 1: sum = 337, aver = 84
|
|
|
|
|
|
|
|
course 2: sum = 364, aver = 91
|
|
|
|
|
|
|
|
course 3: sum = 383, aver = 95
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### C7: 学生总分排序
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
如果a < b,则按升序排列。选择菜单命令 4 ,按选择法将数组 sum 的元素值按升序进行排序,显示提示信息,最后打印出学生信息。
|
|
|
|
|
|
|
|
如果a > b,则按降序排序。选择菜单命令 5 ,按选择法将数组 sum 的元素值按降序进行排序,显示提示信息,最后打印出学生成绩。
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
Please Input your choice: 4
|
|
|
|
|
|
|
|
Sort in descending order by score:
|
|
|
|
|
|
|
|
2214111006 XuZilin 100 95 86 281 93
|
|
|
|
|
|
|
|
2214111011 ZhangYu 85 91 98 274 91
|
|
|
|
|
|
|
|
2214111009 XuZigui 77 89 99 265 88
|
|
|
|
|
|
|
|
2214111025 LiYujia 75 89 100 264 88
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Please Input your choice: 5
|
|
|
|
|
|
|
|
Sort in ascending order by score:
|
|
|
|
|
|
|
|
2214111025 LiYujia 75 89 100 264 88
|
|
|
|
|
|
|
|
2214111009 XuZigui 77 89 99 265 88
|
|
|
|
|
|
|
|
2214111011 ZhangYu 85 91 98 274 91
|
|
|
|
|
|
|
|
2214111006 XuZilin 100 95 86 281 93
|
|
|
|
|
|
|
|
|
|
|
|
### C7:按学号由小到大排出成绩表
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
选择菜单命令6,将结构体中的学号按升序排序,在此功能中需要注意的是将整组数据随着学号一起改变,首先提示学号按升序排列,接着调用函数实现其功能,最后调用函数打印学生成绩
|
|
|
|
### C8: 学号顺序排序
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
选择菜单命令 6 ,按学号从小到大进行排序,显示提示信息,最后打印学生信息。
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
Please Input your choice: 6
|
|
|
|
Sort in ascending order by number:
|
|
|
|
Sort in ascending order by number:
|
|
|
|
|
|
|
|
2214111006 XuZilin 100 95 86 281 93
|
|
|
|
|
|
|
|
2214111009 XuZigui 77 89 99 265 88
|
|
|
|
|
|
|
|
2214111011 ZhangYu 85 91 98 274 91
|
|
|
|
|
|
|
|
2214111025 LiYujia 75 89 100 264 88
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
### C8:按姓名的字母顺序排出成绩表
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
选择菜单命令7,将结构体中的姓名字母按一定顺序排序,在此功能中需要注意的是将整组数据随着姓名一起改变,首先调用函数实现其功能,接着提示姓名按升序排列,最后调用函数打印学生成绩
|
|
|
|
### C9: 姓名顺序排序
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
选择菜单命令 7 ,按姓名的字典顺序进行排序,显示提示信息,最后打印学生信息。
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
Please Input your choice: 7
|
|
|
|
Sort in dictionary order by name:
|
|
|
|
Sort in dictionary order by name:
|
|
|
|
|
|
|
|
2214111025 LiYujia 75 89 100 264 88
|
|
|
|
|
|
|
|
2214111009 XuZigui 77 89 99 265 88
|
|
|
|
|
|
|
|
2214111006 XuZilin 100 95 86 281 93
|
|
|
|
|
|
|
|
2214111011 ZhangYu 85 91 98 274 91
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### C10: 学生信息查询
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- 选择菜单命令 8 ,提示输入学生学号,若该学号存在,则输出学生信息;否则提示没有找到并结束。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
Please Input your choice: 8
|
|
|
|
|
|
|
|
Input the number you want to search:2214111011
|
|
|
|
|
|
|
|
2214111011 ZhangYu 85 91 98 274 91
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 Input record
|
|
|
|
|
|
|
|
2 Calculate total and average score of every course
|
|
|
|
|
|
|
|
3 Calculate total and average score of every student
|
|
|
|
|
|
|
|
4 Sort in descending order by score
|
|
|
|
|
|
|
|
5 Sort in ascending order by score
|
|
|
|
|
|
|
|
6 Sort in ascending order by number
|
|
|
|
|
|
|
|
7 Sort in dictionary order by name
|
|
|
|
|
|
|
|
8 Search by number
|
|
|
|
|
|
|
|
9 Search by name
|
|
|
|
|
|
|
|
10 Statistic analysis
|
|
|
|
|
|
|
|
11 List record
|
|
|
|
|
|
|
|
12 Write to a file
|
|
|
|
|
|
|
|
13 Read from a file
|
|
|
|
|
|
|
|
0 Exit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Please Input your choice: 8
|
|
|
|
|
|
|
|
Input the number you want to search:2214111001
|
|
|
|
|
|
|
|
Not found!
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
### C9:按学号查询学生排名及其考试成绩
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
选择菜单命令8,依据学号查找学生排名及考试成绩然后打印出来。输入学号,然后再循环体中对结构体进行遍历,如果找到所查找的结构体的下标值,将该下标值对应学生的信息打印出来。如果没有找到,则提示“Not found!"
|
|
|
|
- 选择菜单命令 9 ,提示输入学生姓名,若该姓名存在,则输出学生信息;否则提示没有找到并结束。
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
Input the number you want to search:
|
|
|
|
Please Input your choice: 9
|
|
|
|
|
|
|
|
Input the name you want to search:LiYujia
|
|
|
|
|
|
|
|
2214111025 LiYujia 75 89 100 264 88
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 Input record
|
|
|
|
|
|
|
|
2 Calculate total and average score of every course
|
|
|
|
|
|
|
|
3 Calculate total and average score of every student
|
|
|
|
|
|
|
|
4 Sort in descending order by score
|
|
|
|
|
|
|
|
5 Sort in ascending order by score
|
|
|
|
|
|
|
|
6 Sort in ascending order by number
|
|
|
|
|
|
|
|
7 Sort in dictionary order by name
|
|
|
|
|
|
|
|
8 Search by number
|
|
|
|
|
|
|
|
9 Search by name
|
|
|
|
|
|
|
|
10 Statistic analysis
|
|
|
|
|
|
|
|
11 List record
|
|
|
|
|
|
|
|
12 Write to a file
|
|
|
|
|
|
|
|
13 Read from a file
|
|
|
|
|
|
|
|
0 Exit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Please Input your choice: 9
|
|
|
|
|
|
|
|
Input the name you want to search:SunYizhe
|
|
|
|
Not found!
|
|
|
|
Not found!
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### C11:按姓名查询学生排名及考试成绩
|
|
|
|
### C11: 统计各分数段学生人数及所占百分比
|
|
|
|
|
|
|
|
|
|
|
|
选择菜单命令9,依据姓名查找学生排名及考试成绩然后打印出来。输入姓名,然后再循环体中对结构体进行遍历,如果找到所查找的结构体的下标值,将该下标值对应学生的信息打印出来。如果没有找到,则提示“Not found!"
|
|
|
|
选择菜单命令 10,提示输入学生成绩,通过循环得出各分数段学生人数及所占百分比
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
Input the name you want to search:
|
|
|
|
Please Input your choice: 10
|
|
|
|
Not found!
|
|
|
|
For course 1:
|
|
|
|
|
|
|
|
<60 0 0.00%
|
|
|
|
|
|
|
|
60-70 0 0.00%
|
|
|
|
|
|
|
|
70-80 2 50.00%
|
|
|
|
|
|
|
|
80-90 1 25.00%
|
|
|
|
|
|
|
|
90-100 0 0.00%
|
|
|
|
|
|
|
|
100 1 25.00%
|
|
|
|
|
|
|
|
For course 2:
|
|
|
|
|
|
|
|
<60 0 0.00%
|
|
|
|
|
|
|
|
60-70 0 0.00%
|
|
|
|
|
|
|
|
70-80 0 00.00%
|
|
|
|
|
|
|
|
80-90 2 50.00%
|
|
|
|
|
|
|
|
90-100 2 50.00%
|
|
|
|
|
|
|
|
100 0 0.00%
|
|
|
|
|
|
|
|
For course 3:
|
|
|
|
|
|
|
|
<60 0 0.00%
|
|
|
|
|
|
|
|
60-70 0 0.00%
|
|
|
|
|
|
|
|
70-80 0 0.00%
|
|
|
|
|
|
|
|
80-90 1 25.00%
|
|
|
|
|
|
|
|
90-100 2 50.00%
|
|
|
|
|
|
|
|
100 1 25.00%
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
### C12: 打印学生信息
|
|
|
|
|
|
|
|
|
|
|
|
### C12:统计各分数段的学生人数及所占的百分比
|
|
|
|
选择菜单命令11,打印
|
|
|
|
|
|
|
|
|
|
|
|
按优秀(90-100)、良好(80-89)、中等(70-79)、及格(60-69)、不及格(0-59)5个类别,对每门课程分别统计每个类别的人数以及所占的百分比
|
|
|
|
```
|
|
|
|
|
|
|
|
Please Input your choice: 11
|
|
|
|
|
|
|
|
2214111006 XuZilin 100 95 86 281 93
|
|
|
|
|
|
|
|
2214111009 XuZigui 77 89 99 265 88
|
|
|
|
|
|
|
|
2214111011 ZhangYu 85 91 98 274 91
|
|
|
|
|
|
|
|
2214111025 LiYujia 75 89 100 264 88
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### C13: 将学生信息保存在文件中
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
选择菜单命令 12 ,将学生信息保存在文件 student.txt 中。如果文件不存在,则给出错误信息并退出程序,否则逐个读入
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
Please Input your choice: 12
|
|
|
|
|
|
|
|
Failure to open score.txt!
|
|
|
|
|
|
|
|
|
|
|
|
### C13:打印学生成绩
|
|
|
|
1 Input record
|
|
|
|
|
|
|
|
2 Calculate total and average score of every course
|
|
|
|
|
|
|
|
3 Calculate total and average score of every student
|
|
|
|
|
|
|
|
4 Sort in descending order by score
|
|
|
|
|
|
|
|
5 Sort in ascending order by score
|
|
|
|
|
|
|
|
6 Sort in ascending order by number
|
|
|
|
|
|
|
|
7 Sort in dictionary order by name
|
|
|
|
|
|
|
|
8 Search by number
|
|
|
|
|
|
|
|
9 Search by name
|
|
|
|
|
|
|
|
10 Statistic analysis
|
|
|
|
|
|
|
|
11 List record
|
|
|
|
|
|
|
|
12 Write to a file
|
|
|
|
|
|
|
|
13 Read from a file
|
|
|
|
|
|
|
|
0 Exit
|
|
|
|
|
|
|
|
|
|
|
|
输出每个学生的学号、姓名、各科考试成绩、以及每门课程的总分和平均分
|
|
|
|
Please Input your choice: 12
|
|
|
|
|
|
|
|
2214111006 XuZilin 100 95 86 281 93
|
|
|
|
|
|
|
|
2214111009 XuZigui 77 89 99 265 88
|
|
|
|
|
|
|
|
2214111011 ZhangYu 85 91 98 274 91
|
|
|
|
|
|
|
|
2214111025 LiYujia 75 89 100 264 88
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### 从文件中读取学生信息
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
选择菜单命令 13 ,从文件中读取学生的学号、姓名及成绩等信息写入到结构体数组 stu 中。如果文件为空,则给出错误信息并退出程序,反之,逐个读入
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
Please Input your choice: 13
|
|
|
|
|
|
|
|
Failure to open score.txt!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 Input record
|
|
|
|
|
|
|
|
2 Calculate total and average score of every course
|
|
|
|
|
|
|
|
3 Calculate total and average score of every student
|
|
|
|
|
|
|
|
4 Sort in descending order by score
|
|
|
|
|
|
|
|
5 Sort in ascending order by score
|
|
|
|
|
|
|
|
6 Sort in ascending order by number
|
|
|
|
|
|
|
|
7 Sort in dictionary order by name
|
|
|
|
|
|
|
|
8 Search by number
|
|
|
|
|
|
|
|
9 Search by name
|
|
|
|
|
|
|
|
10 Statistic analysis
|
|
|
|
|
|
|
|
11 List record
|
|
|
|
|
|
|
|
12 Write to a file
|
|
|
|
|
|
|
|
13 Read from a file
|
|
|
|
|
|
|
|
0 Exit
|
|
|
|
|
|
|
|
|
|
|
|
### C14:将每个学生的记录信息写入文件
|
|
|
|
Please Input your choice: 13
|
|
|
|
|
|
|
|
2214111006 XuZilin 100 95 86 281 93
|
|
|
|
|
|
|
|
2214111009 XuZigui 77 89 99 265 88
|
|
|
|
|
|
|
|
2214111011 ZhangYu 85 91 98 274 91
|
|
|
|
|
|
|
|
2214111025 LiYujia 75 89 100 264 88
|
|
|
|
|
|
|
|
|
|
|
|
### C15:从文件中读出每个学生的记录信息并显示
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## 功能设计
|
|
|
|
## 功能设计
|
|
|
|
|
|
|
|
|
|
|
|