XZG_main函数详细实现流程图
Cx330 2 years ago
parent 156688b21c
commit b8f9ee46db

@ -68,20 +68,20 @@ Input course number(m<=%d):
``` ```
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
4.Sort in descending order by score 4 Sort in descending order by score
5.Sort in ascending order by score 5 Sort in ascending order by score
6.Sort in ascending order by number 6 Sort in ascending order by number
7.Sort in dictionary order by name 7 Sort in dictionary order by name
8.Search by number 8 Search by number
9.Search by name 9 Search by name
10.Statistic analysis 10 Statistic analysis
11.List record 11 List record
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: //用户输入选项后将结果返回到主函数
``` ```
@ -280,7 +280,8 @@ int main(void)
break; break;
case 13:ReadfromFile(stu,&n,&m); case 13:ReadfromFile(stu,&n,&m);
break; break;
case 0:printf("End of program!); case 0: printf("Are you sure you want to exit?(Y/N):");
printf("End of program!);
exit(0); exit(0);
default:printf("Input error!"); default:printf("Input error!");
} }
@ -295,20 +296,20 @@ int Menu(void)
{ {
int itemSelected; int itemSelected;
printf("Management for Students' scores\n"); printf("Management for Students' scores\n");
printf("1.Input record\n"); printf("1 Input record\n");
printf("2.Calculate total and average score of every course\n"); printf("2 Calculate total and average score of every course\n");
printf("3.Calculate total and average score of every student\n"); printf("3 Calculate total and average score of every student\n");
printf("4.Sort in descending order by score\n"); printf("4 Sort in descending order by score\n");
printf("5.Sort in ascending order by score\n"); printf("5 Sort in ascending order by score\n");
printf("6.Sort in ascending order by number\n"); printf("6 Sort in ascending order by number\n");
printf("7.Sort in dictionary order by name\n"); printf("7 Sort in dictionary order by name\n");
printf("8.Search by number\n"); printf("8 Search by number\n");
printf("9.Search by name\n"); printf("9 Search by name\n");
printf("10.Statistic analysis\n"); printf("10 Statistic analysis\n");
printf("11.List record\n"); printf("11 List record\n");
printf("12.Write to a file\n"); printf("12 Write to a file\n");
printf("13.Read from a file\n"); printf("13 Read from a file\n");
printf("0.Exit\n"); printf("0 Exit\n");
printf("Please Input your choice:"); printf("Please Input your choice:");
scanf("%d",&itemSelected); //读入用户输入 scanf("%d",&itemSelected); //读入用户输入
return itemSelected; return itemSelected;
@ -363,7 +364,7 @@ void AverSumofEveryCourse(STU stu[],int n,int m)
} }
aver[j] = sum[j]/i; aver[j] = sum[j]/i;
printf("student %d: sum = %.0f,aver = %.0f\n",j+1, sum[j], aver[j]); printf("course %d: sum = %.0f,aver = %.0f\n",j+1, sum[j], aver[j]);
} }
} }
``` ```

@ -0,0 +1,155 @@
### 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 ,按学号查找学生成绩并显示查找结果。
Loading…
Cancel
Save