1、C语言课程方案设计书报告运动会分数统计系统封面作者:PanHongliang仅供个人学习一.需求分析1问题描述运动会分数统计系统参加运动会有n个系,系编号为1n。比赛分成m个男子工程,和w个女子工程。工程编号为男子1m,女子m+1m+w。不同的工程取前五名或前三名积分;取前五名的积分分别为:7、5、3、2、1,前三名的积分分别为:5、3、2;哪些取前五名或前三名由学生自己设定。(m=20,n=20)2.基本要求:(1). 运动员检录;(2)运动员检录,(3)运动员成绩排序;(4). 运动员评奖3.测试数据1输入:1进入添加系的界面,根据提示,再输入:汽车系。再输入:8,成功添加了一个系。再输入
2、:2进入运动工程添加界面,根据提示,再输入:跳高;1;0;1;2;3。之后输入0。再次进入系统界面。2输入:3查看输出结果。3:输入:4查看输出结果。4:输入:5查看输出结果。5:输入:6查看输出结果。6:输入:7根据提示输入工程编号:2。查看输出结果。7:输入:8根据提示输入系编号:3。查看输出结果。二、概要设计 1.数据结构系:名称,编号,男子团体总分,女子固体总分。运动工程:工程编号,名称,男子工程,女子工程,前三名,前五名,第一名系的编号,第二名系的编号,第三名系的编号,第四名系的编号,第五名系的编号。2.程序模块及之间的调用关系三、详细设计 1、数据类型定义 (1)系的定义:type
3、def struct Department /系的结构char name20。 /系的名称int number。 /系的编号int boy。 /男子团体总分int girl。 /女子团体总分Department *next。 Department。(2)运动工程定义:typedef struct Sport /运动工程结构char name20。 /运动工程名称int isboy。 /0为女工程,1为男工程int is3。 /0为取前五名,1为取前五名 int number。 /工程编号int first。 /第一名系的编号int second。 /第二名系的编号int third。 /第三名
4、系的编号int fourth。 /第四名系的编号int fifth。 /第五名系的编号Sport *next。Sport。、2、函数之间的调用关系(1)系调用图 department_add department_OrderDepartment department_search department_addmark department_show department_isexist department_output department_read department_write department_getlong sport_isexist sport_add sport_getlo
5、ng sport_writeSport sport_read sport_output sport_search3、算法设计 主要算法的设计思想: 本程序主要是使用链表来实现操作。一个运动会包括运动工程和参加运动会的成员。因此构造两个链表Department,Sport。为了操作的方便,并且能够保存输入数据,所以通过文件操作来实现数据的写和读。每次添加新的数据后都要输入0退出,数据才能保存。对于总分的排序使用了冒泡排序。为了使整个程序看起来更加友好,又添加了程序启动画面。4、调试分析 本程序相对来说比较容易看明白,其中涉及到的一些函数相对来说比较容易。通过调试,运行,基本上达到了要求,但还存在
6、一些缺点。如:不够人性化等。5、测试结果 多组数据输入与输出:(1)输入:3输出:系名 编号 男团总分 女团总分 总分 法律系 6 0 0 0 电子系 5 3 2 5 数学系 4 6 0 6 历史系 3 9 7 16 中文系 2 15 11 26 计算机系 1 21 11 32 旅游系 7 0 7 7(2)输入:4输出: 系名 编号 男团总分 女团总分 总分 法律系 6 0 0 0 电子系 5 3 2 5 数学系 4 6 0 6旅游系 7 0 7 7 历史系 3 9 7 16 中文系 2 15 11 26 计算机系 1 21 11 32(3)输入:5输出:法律系 6 0 0 0 电子系 5 3
7、 2 5 数学系 4 6 0 6 旅游系 7 0 7 7 历史系 3 9 7 16 中文系 2 15 11 26 计算机系 1 21 11 32 (4)输入:6 输出:法律系 6 0 0 0 电子系 5 3 2 5 数学系 4 6 0 6旅游系 7 0 7 7 历史系 3 9 7 16 中文系 2 15 11 26 计算机系 1 21 11 32(5)输入:7 输出:请输入工程编号: 输入:1回车 输出: 工程名:100m 工程类型:女子工程 第一名:计算机系 第二名:中文系 第三名:法律系 第四名:无 第五名:无 (6)输入:8 输出:请输入系的编号: 再输入2 则输出: 系名:中文系 男子
8、团体总分:3 女子团体部分:10 总分:13 (7)输入:0 退出6、用户手册1、运行环境 Windows,VC+6.0 2、用户界面 4、操作过程 (1)用户进入程序启动界面,等load完成后进入主菜单.主菜单有以下9个选项 1.输入系别 2.输入运动工程 3.按系别编号输出总分 4.按总分排序 5.按男团体总分排序 6.按女团体总分排序 7.按工程编号查询 8.按系别编号查询 0.退出 (2)输入08中的一个数 (3)输入1,进行添加系操作,分别输入系的名称和编号 (4)输入2,进行添加运动工程操作,分别输入工程名称,编号,工程类型,名次选 取,排名情况 (5)输入0,则退出系统,并且保存
9、输入的信息.每次添加完都要输入0退出系统 才有效 (6)输入3,输出按系编号总分排名. (7)输入4,输出按总分排名 (8)输入5,输出按男团体总分排序 (9)输入6,输出按女团体总分排序 (10)输入7,进入按工程编号查询界面.输入要查询的工程编号 (11)输入8,进入按系别编号查询界面,输入要查询的系的编号7、参考文献【1】C+程序设计作者:郑莉,董渊,张瑞丰 出版社:清华大学出版社 时间:2003/12【2】数据结构作者:严蔚敏,吴伟民 出版社:清华大学出版社 时间:2006/10【3】数据结构教程上机实验指导作者:严蔚敏,吴伟民,M宁 出版社:清华大学出版 社 时间:2006/5【4】
10、 网址: 8、附录 1、源程序 #include#include#include#include#include#include#include#includetypedef struct Department /系的结构 char name20。 /系的名称 int number。 /系的编号 int boy。 /男子团体总分 int girl。 /女子团体总分 Department *next。 Department。typedef struct Sport /运动工程结构 char name20。 /运动工程名称 int isboy。 /0为女工程,1为男工程 int is3。 /0为取
11、前五名,1为取前五名 int number。 /工程编号 int first。 /第一名系的编号 int second。 /第二名系的编号 int third。 /第三名系的编号 int fourth。 /第四名系的编号 int fifth。 /第五名系的编号 Sport *next。Sport。int getint(int a) /字符转换成数字 return (int)(a-0)。Department * head1。/-启动画面函数-void Cover() system(color 1b)。 char line=程序读取中请耐心等待.。 char bar=.。 int i,j,k=0,
12、x=0,y=0。 for(i=0。i=strlen(line)/2。) system(cls)。 for(j=0。j9。j+) /改变行坐标 coutendl。 for(j=0。j(75-strlen(line)/2。j+) /改变列坐标 cout 。 for(j=1。j=i。j+) /进度显示器 couti。x-) cout。 if(k=4) i+。 coutendl。 for(j=0。j(75-strlen(line)/2。j+) /行坐标定位 cout 。 coutline。 /输出线条 coutendl。 for(j=0。j(65-strlen(bar)/2。j+) cout 。 co
13、ut(i+7)*5% Loading。 cout.write(bar,k)。 coutendl。 for(j=0。j10。j+) coutendl。 for(j=0。j24。j+) cout 。 cout程序设计员5080906 石行endl。 for(j=0。j24。j+) cout 。 for(j=0。j=18。j+) cout。 coutendl。 for(j=0。j4) k=0。 void department_add() /添加系 Department * p。 int mark=0。 p=new Department。 coutp-name。 char c。 while (mark
14、!=1) coutc。 if (!isdigit(c)/是否为数字 cout数据非法number=c。 p-boy=0。 p-girl=0。 p-next=head1-next。 head1-next=p。 cout成功添加了一个系next!=NULL) i+。 first=first-next。 return i。void department_write()/将系数据写入文本 Department * p。 p=head1。 p=p-next。 ofstream outfile(Department.txt,ios:out)。 outfiledepartment_getlong(p)+1
15、。 while (p!=NULL) outfilename number boy girlnext。 outfile.close()。 coutWrite Success!i。 while(i0) Department * p。 p=new Department。 infilep-namep-numberp-boyp-girl。 p-next=head1-next。 head1-next=p。 i-。 coutDepartment Data Read Success!endl。void department_output(Department *p)/输出系 cout系名编号男团总分女团总分总
16、分tn。 while(p) coutname tnumber)tboytgirlt girl+p-boy)next。 int department_isexist(int a)/检验系是否存在 int b=0。 Department *p。 p=head1。 p=p-next。 while(p) if(p-number=a) return 1。 p=p-next。 return 0。void department_show(int a)/输出所有系 Department *p。 p=head1。 p=p-next。 while(p) if(p-number=a) coutnamenext。 c
17、outnext。 while(p) if(p-number=a) cout系名:name男子团体总分:boy女子团体总分:girl总分:boy+p-girl)next。 coutnext。 while(p) if(p-number=b) if(c=1) p-boy=p-boy+a。 else p-girl=p-girl+a。 p=p-next。 void department_order(Department *temp,int type) /type=0按总分,type=1按男总分,type=2按女总分, Department *p,*q,*small,*temp1。 temp1=new D
18、epartment。 temp1-next=NULL。 p=temp。 while(p) small=p。 q=p-next。 while(q) switch(type) case 0: if(q-boy+q-girl)girl+small-boy) small=q。 break。 case 1: if(q-boyboy) small=q。 break。 case 2: if(q-girlgirl) small=q。 break。 default: couterrorboy=p-boy。 p-boy=small-boy。 small-boy=temp1-boy。 temp1-girl=p-gi
19、rl。 p-girl=small-girl。 small-girl=temp1-girl。 strcpy(temp1-name,p-name)。 strcpy(p-name,small-name)。 strcpy(small-name,temp1-name)。 temp1-number=p-number。 p-number=small-number。 small-number=temp1-number。 /将系的名字互换 q=q-next。 p=p-next。 Sport * head2。int sport_isexist(int a) /检查运动工程(编号)是否已经存在 int b=0。 S
20、port *p。 p=head2。 p=p-next。 while(p) if(p-number=a) return 1。 p=p-next。 return 0。void sport_add() /添加工程 Sport * p。 int mark=0。 p=new Sport。 coutp-name。 char c。 while (mark!=1) coutc。 if (!isdigit(c) cout数据非法endl。 else if(sport_isexist(c) cout该编号已存在number=c。 mark=0。 while (mark!=1) coutc。 p-isboy=(in
21、t)(c-0)。/字符转换成数字 if (!isdigit(c) cout数据非法isboyisboy1) cout数据非法isboy=c。 mark=0。 while (mark!=1) coutc。 p-is3=(int)(c-0)。 if (!isdigit(c) cout数据非法is3is31) cout数据非法is3=c。 mark=0。 while (mark!=1) coutc。 if (!isdigit(c) cout数据非法endl。 else if(!department_isexist(c) coutfirst=c。 if(p-is3=0) department_addm
22、ark(5,c,p-isboy)。 else department_addmark(7,c,p-isboy)。 mark=0。 while (mark!=1) coutc。 if (!isdigit(c) cout数据非法endl。 else if(!department_isexist(c) coutsecond=c。 if(p-is3=0) department_addmark(3,c,p-isboy)。 else department_addmark(5,c,p-isboy)。 mark=0。 while (mark!=1) coutc。 if (!isdigit(c) cout数据非法endl。 else if(!department_isexist(c) coutthird=c。 if(p-is3=0) department_addmark(2,c,p-isboy)。 else department_addmark(3,c,p-isboy)。 mark=0。 if(p-is3=1) while (mark!=1) cout请输入第
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1