成绩管理系统V60Word下载.docx
- 文档编号:20928822
- 上传时间:2023-01-26
- 格式:DOCX
- 页数:25
- 大小:224.56KB
成绩管理系统V60Word下载.docx
《成绩管理系统V60Word下载.docx》由会员分享,可在线阅读,更多相关《成绩管理系统V60Word下载.docx(25页珍藏版)》请在冰豆网上搜索。
查找:
通过多种方式如学号,姓名查找特定学生的成绩
3.数据结构
退出
用户输入指令
4.各模块(函数)的功能和接口设计:
序号
函数名
函数功能
函数参数
1
Menu
显示菜单获得输入的选项
无
2
Readscore
录入学生信息
STUstu[],m,n
3
Aversumofeverystudent
计算每个学生总成绩平均值
4
Aversumofeverycourse
计算每门课程总成绩平均成绩
5
Sortbyscore
按成绩排序
6
Ascending
升序
floata,b
7
Descending
降序
8
Assortbynum
按学号排序
9
Sortbyname
按姓名排序
10
Searchbynum
按学号查询学生信息
11
Searchbyname
按姓名查询学生信息
12
StatisticAnlysis(STUstu[],intn,intm)
分析学生成绩五个分数段所占百分比
13
PrintScore
打印输出学生成绩
14
WritetoFile
写入程序D盘student.txt
15
ReadfromFile
读取文件
4系统实现
1.系统的总流程图:
显示菜单——>
输入用户的选择——>
根据用户的输入选择不同的操作
case1:
Readscore(stu,n,m);
break;
case2:
Aversumofeverystudent(stu,n,m);
case3:
Aversumofeverycourse(stu,n,m);
case4:
Sortbyscore(stu,n,m,Descending);
printf("
\n成绩降序排序\n"
);
Printscore(stu,n,m);
case5:
Sortbyscore(stu,n,m,Ascending);
\n成绩升序排序\n"
case6:
Assortbynum(stu,n,m);
\n学号升序排序\n"
case7:
Sortbyname(stu,n,m);
\n姓名升序排序\n"
case8:
Searchbynum(stu,n,m);
case9:
Searchbyname(stu,n,m);
case10:
StatisticAnlysis(stu,n,m);
case11:
case12:
Writetofile(stu,n,m);
case13:
Readfromfile(stu,&
n,&
m);
break;
case0:
Endofprogram!
\n"
exit(0);
2.程序的全部源代码:
1#include<
stdio.h>
2#include<
stdlib.h>
3#include<
string.h>
4typedefstructstudent
5{
6longnum;
7charname[10];
8floatscore[6];
9floatsum;
10floataver;
11}STU;
12intMenu(void);
13voidReadScore(STUstu[],intn,intm);
14voidAverSumofEveryStudent(STUstu[],intn,intm);
15voidAverSumofEveryCourse(STUstu[],intn,intm);
16voidSortbyScore(STUstu[],intn,intm,int(*compare)(floata,floatb));
17intAscending(floata,floatb);
18intDescending(floata,floatb);
19voidSwapFloat(float*x,float*y);
20voidSwapLong(long*x,long*y);
21voidSwapChar(charx[],chary[]);
22voidAsSortbyNum(STUstu[],intn,intm);
23voidSortbyName(STUstu[],intn,intm);
24voidSearchbyNum(STUstu[],intn,intm);
25voidSearchbyName(STUstu[],intn,intm);
26voidStatisticAnalysis(STUstu[],intn,intm);
27voidPrintScore(STUstu[],intn,intm);
28voidWritetoFile(STUstu[],intn,intm);
29voidReadfromFile(STUstu[],int*n,int*m);
30intmain()
31{
32charch;
33intn=0,m=0;
34
35STUstu[30];
36
37printf("
Inputstudentnumber:
(lessthan30)\n"
38scanf("
%d"
&
n);
39
40printf("
Inputcoursenumber:
(lessthan6)\n"
41scanf("
42
43while
(1)
44{
45ch=Menu();
46switch(ch)
47{
48case1:
ReadScore(stu,n,m);
49break;
50case2:
AverSumofEveryCourse(stu,n,m);
51break;
52case3:
AverSumofEveryStudent(stu,n,m);
53break;
54case4:
SortbyScore(stu,n,m,Descending);
55printf("
\nSortindescendingorderbyscore:
\n"
56PrintScore(stu,n,m);
57break;
58case5:
SortbyScore(stu,n,m,Ascending);
59printf("
\nSortinascendingorderbyscore:
60PrintScore(stu,n,m);
61break;
62case6:
AsSortbyNum(stu,n,m);
63printf("
\nSortinascendingorderbynumber:
64PrintScore(stu,n,m);
65break;
66case7:
SortbyName(stu,n,m);
67printf("
\nSortindictionaryorderbyname:
68PrintScore(stu,n,m);
69break;
70case8:
SearchbyNum(stu,n,m);
71break;
72case9:
SearchbyName(stu,n,m);
73break;
74case10:
StatisticAnalysis(stu,n,m);
75break;
76case11:
PrintScore(stu,n,m);
77break;
78case12:
WritetoFile(stu,n,m);
79break;
80case13:
ReadfromFile(stu,&
81break;
82case0:
83exit(0);
84
85default:
printf("
Inputerror!
86}
87}
88return0;
89}
90/*Menu:
显示菜单并获得用户键盘输入的选项*/
91intMenu(void)
92{
93inta;
94
95printf("
ManagementforStudents'
scores\n"
96printf("
1.Inputrecord\n"
97printf("
2.Caculatetotalandaveragescoreofeverycourse\n"
98printf("
3.Caculatetotalandaveragescoreofeverystudent\n"
99printf("
4.Sortindescendingorderbyscore\n"
100printf("
5.Sortinascendingorderbyscore\n"
101printf("
6.Sortinascendingorderbynumber\n"
102printf("
7.Sortindictionaryorderbyname\n"
103printf("
8.Searchbynumber\n"
104printf("
9.Searchbyname\n"
105printf("
10.Statisticanalysis\n"
106printf("
11.Listrecord\n"
107printf("
12.Writetoafile\n"
108printf("
13.Readfromafile\n"
109printf("
0.Exit\n"
110printf("
PleaseInputyourchoice:
"
111
112scanf("
a);
113
114returna;
115
116}
117/*input:
输入每个学生每门课的成绩*/
118voidReadScore(STUstu[],intn,intm)
119{
120inti,j,k;
121
122printf("
Inputstudent'
sID,nameandscore:
123
124for(i=0;
i<
n;
i++)
125{
126
127scanf("
%ld%s"
stu[i].num,stu[i].name);
128
129for(j=0;
j<
m;
j++)
130{
131scanf("
%f"
stu[i].score[j]);
132}
133
134}
135}
136/*AverSumofEveryStudent:
计算每个学生每门课的总分和平均分*/
137voidAverSumofEveryStudent(STUstu[],intn,intm)
138{
139inti,j;
140
141for(i=0;
142{
143stu[i].sum=0;
144
145for(j=0;
146{
147stu[i].sum=stu[i].sum+stu[i].score[j];
148}
149
150stu[i].aver=m>
0?
stu[i].sum/m:
-1;
151
152printf("
student%d:
sum=%.0f,aver=%.0f\n"
i+1,stu[i].sum,stu[i].aver);
153}
154}
155/*AverSumofEveryCourse:
计算每门课程的总分和平均分*/
156voidAverSumofEveryCourse(STUstu[],intn,intm)
157{
158inti,j;
159floatsum[6],aver[6];
160
161for(j=0;
162{
163sum[j]=0;
164
165for(i=0;
166{
167sum[j]=sum[j]+stu[i].score[j];
168}
169
170aver[j]=n>
0?
sum[j]/n:
-1;
171
172printf("
course%d:
sum=%.0f,aver=%.0f\n"
j+1,sum[j],aver[j]);
173}
174}
175/*SortbyScore:
将每个学生按总成绩排序*/
176voidSortbyScore(STUstu[],intn,intm,int(*compare)(floata,floatb))
177{
178inti,j,k,t;
179
180for(i=0;
n-1;
181{
182k=i;
183
184for(j=i+1;
185{
186if((*compare)(stu[j].sum,stu[k].sum))
187k=j;
188}
189
190if(k!
=i)
191{
192for(t=0;
t<
t++)
193{
194SwapFloat(&
stu[k].score[t],&
stu[i].score[t]);
195}
196
197SwapFloat(&
stu[k].sum,&
stu[i].sum);
198SwapFloat(&
stu[k].aver,&
stu[i].aver);
199SwapLong(&
stu[k].num,&
stu[i].num);
200SwapChar(stu[k].name,stu[i].name);
201}
202}
203}
204/*Ascending:
按照升序*/
205intAscending(floata,floatb)
206{
207returna<
b;
208}
209/*Descending:
按照降序*/
210intDescending(floata,floatb)
211{
212returna>
213}
214/*SwapFloat:
交换单精度浮点型数据*/
215voidSwapFloat(float*x,float*y)
216{
217floattemp;
218
219temp=*x;
220*x=*y;
221*y=temp;
222}
223/*SwapLong交换长整形数据*/
224voidSwapLong(long*x,long*y)
225{
226longtemp;
227
228temp=*x;
229*x=*y;
230*y=temp;
231}
232/*SwapChar交换字符型数据*/
233voidSwapChar(charx[],chary[])
234{
235chartemp[10];
236
237strcpy(temp,x);
238strcpy(x,y);
239strcpy(y,temp);
240}
241/*AsSortbyNum:
将学生按照学号顺序排列*/
242voidAsSortbyNum(STUstu[],intn,intm)
243{
244inti,j,k,t;
245
246for(i=0;
247{
248k=i;
249for(j=i+1;
250{
251if(stu[j].num<
stu[k].num)
252k=j;
253}
254if(k!
255{
256for(t=0;
257{
258SwapFloat(&
259}
260
261SwapFloat(&
262SwapFloat(&
263SwapLong(&
264SwapChar(stu[k].name,stu[i].name);
265}
266}
267}
268/*SortbyName:
将学生按照字典顺序排列*/
269voidSortbyName(STUstu[],intn,intm)
270{
271inti,j,t;
272
273for(i=0;
274{
275for(j=i+1;
276{
277if(strcmp(stu[j].name,stu[i].name)<
0)
278{
279for(t=0;
280{
281SwapFloat(&
stu[i].score[t],&
stu[j].score[t]);
282}
283
284SwapFloat(&
stu[i].sum,&
stu[j].sum);
285SwapFloat(&
stu[i].aver,&
stu[j].aver);
286SwapLong(&
stu[i].num,&
stu[j].num);
287SwapChar(stu[i].name,stu[j].name);
288}
289}
290}
291}
292/*SearchbyNum:
按学号查找并打印学生成绩*/
293voidSearchbyNum(STUstu[],intn,intm)
294{
295longnumber;
296inti,j;
297
298printf("
Inputthenumberyouwanttosearch"
299scanf("
%ld"
number);
300
301for(i=0;
302{
303if(stu[i].num==number)
304{
305printf("
%ld\t%s\t"
stu[i].num,stu[i].name);
306
307for(j=0;
308{
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 成绩管理系统 V60
![提示](https://static.bdocx.com/images/bang_tan.gif)