|
|
|
|
### C1: 启动程序
|
|
|
|
|
|
|
|
|
|
命令行中执行命令./app,系统启动,显示提示信息,然后显示功能菜单,等待用户输入命令。
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
Management for Students'scores
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### C2: 显示命令菜单
|
|
|
|
|
|
|
|
|
|
调用 Menu() 函数显示命令菜单,用户输入选项后,将结果返回主函数
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
Management for Students'scores
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### C3: 退出程序
|
|
|
|
|
|
|
|
|
|
选择菜单命令 0 ,再输入 y 确认,则退出程序。
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
Please Input your choice: 0
|
|
|
|
|
Are you sure you want to exit?(Y/N): y
|
|
|
|
|
End of program!
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### C4: 添加学生信息
|
|
|
|
|
|
|
|
|
|
选择菜单命令 1 ,假设n=4,m=3,提示输入学生的学号,姓名和成绩,然后利用循环逐个输入学生的学号和姓名以及各科成绩。
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
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: 计算学生各门课程总分和平均分
|
|
|
|
|
|
|
|
|
|
选择菜单命令 2 ,计算学生各门课程总分和平均分,然后利用循环逐个输出学生的顺序,总成绩和平均分,结果都取整数。
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
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: 计算每门课程的总分和平均分
|
|
|
|
|
|
|
|
|
|
选择菜单命令 3 ,计算每门课程的总分和平均分,然后利用循环逐个输出每门课程的总分和平均分,结果都取整数。
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### C8: 学号顺序排序
|
|
|
|
|
|
|
|
|
|
选择菜单命令 6 ,按学号从小到大进行排序,显示提示信息,最后打印学生信息。
|
|
|
|
|
```
|
|
|
|
|
Please Input your choice: 6
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### C9: 姓名顺序排序
|
|
|
|
|
|
|
|
|
|
选择菜单命令 7 ,按姓名的字典顺序进行排序,显示提示信息,最后打印学生信息。
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
Please Input your choice: 7
|
|
|
|
|
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!
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- 选择菜单命令 9 ,提示输入学生姓名,若该姓名存在,则输出学生信息;否则提示没有找到并结束。
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
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!
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### C11: 统计各分数段学生人数及所占百分比
|
|
|
|
|
|
|
|
|
|
选择菜单命令 10,提示输入学生成绩,通过循环得出各分数段学生人数及所占百分比
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
Please Input your choice: 10
|
|
|
|
|
For course 1:
|
|
|
|
|
```
|