C++课程设计报告运动会分数统计系统1189.pdf

上传人:得****3 文档编号:83884124 上传时间:2023-03-31 格式:PDF 页数:24 大小:760.81KB
返回 下载 相关 举报
C++课程设计报告运动会分数统计系统1189.pdf_第1页
第1页 / 共24页
C++课程设计报告运动会分数统计系统1189.pdf_第2页
第2页 / 共24页
点击查看更多>>
资源描述

《C++课程设计报告运动会分数统计系统1189.pdf》由会员分享,可在线阅读,更多相关《C++课程设计报告运动会分数统计系统1189.pdf(24页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、 C+课程设计报告 运动会分数统计系统 学校:太原科技大学 班级:计算机 07班 姓名:学号:20072001 一.需求分析 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).可以按

2、系编号查询系某个项目的情况;可以按项目编号查询取得前三或前五名的系。3.测试数据 1输入:1 进入添加系的界面,根据提示,再输入:汽车系。再输入:8,成功添加了一个系。再输入:2 进入运动项目添加界面,根据提示,再输入:跳高;1;0;1;2;3。之后输入 0。再次进入系统界面。2输入:3 查看输出结果。3:输入:4 查看输出结果。4:输入:5 查看输出结果。5:输入:6 查看输出结果。6:输入:7 根据提示输入项目编号:2。查看输出结果。7:输入:8 根据提示输入系编号:3。查看输出结果。二、概要设计 1.数据结构 系:名称,编号,男子团体总分,女子固体总分。运动项目:项目编号,名称,男子项目

3、,女子项目,前三名,前五名,第一名系的编号,第二名系的编号,第三名系的编号,第四名系的编号,第五名系的编号。2.程序模块及之间的调用关系 三、详细设计 1、数据类型定义 (1)系的定义:typedef struct Department /系的结构 char name20;/系的名称 int number;/系的编号 int boy;/男子团体总分 int girl;/女子团体总分 Department*next;Department;(2)运动项目定义:typedef struct Sport /运动项目结构 char name20;/运动项目名称 int isboy;/0 为女项目,1 为

4、男项目 int is3;/0 为取前五名,1 为取前五名 int number;/项目编号 int first;/第一名系的编号 int second;/第二名系的编号 int third;/第三名系的编号 int fourth;/第四名系的编号 int fifth;/第五名系的编号 Sport*next;Sport;、2、函数之间的调用关系(1)系调用图 department_add department_Order Department department_search department_addmark department_show department_isexist depar

5、tment_output department_read department_write department_getlong sport_isexist sport_add sport_getlong sport_write Sport sport_read sport_output sport_search 3、算法设计 主要算法的设计思想:本程序主要是使用链表来实现操作。一个运动会包括运动项目和参加运动会的成员。因此构造两个链表 Department,Sport。为了操作的方便,并且能够保存输入数据,所以通过文件操作来实现数据的写和读。每次添加新的数据后都要输入 0 退出,数据才能保存

6、。对于总分的排序使用了冒泡排序。为了使整个程序看起来更加友好,又添加了程序启动画面。四、调试分析 本程序相对来说比较容易看明白,其中涉及到的一些函数相对来说比较容易。通过调试,运行,基本上达到了要求,但还存在一些缺点。如:不够人性化等。五、测试结果 多组数据输入与输出:(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 电子

7、系 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 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 输出:请输入项目编

8、号:输入:1 回车 输出:项目名:100m 项目类型:女子项目 第一名:计算机系 第二名:中文系 第三名:法律系 第四名:无 第五名:无 (6)输入:8 输出:请输入系的编号:再输入 2 则输出:系名:中文系 男子团体总分:3 女子团体部分:10 总分:13 (7)输入:0 退出 六、用户手册 1、运行环境 Windows,VC+6.0 2、用户界面 4、操作过程 (1)用户进入程序启动界面,等 load 完成后进入主菜单.主菜单有以下 9 个选项 1.输入系别 2.输入运动项目 3.按系别编号输出总分 4.按总分排序 5.按男团体总分排序 6.按女团体总分排序 7.按项目编号查询 8.按系别

9、编号查询 0.退出 (2)输入 08 中的一个数 (3)输入 1,进行添加系操作,分别输入系的名称和编号 (4)输入 2,进行添加运动项目操作,分别输入项目名称,编号,项目类型,名次选 取,排名情况 (5)输入 0,则退出系统,并且保存输入的信息.每次添加完都要输入 0 退出系统 才有效 (6)输入 3,输出按系编号总分排名.(7)输入 4,输出按总分排名 (8)输入 5,输出按男团体总分排序 (9)输入 6,输出按女团体总分排序 (10)输入 7,进入按项目编号查询界面.输入要查询的项目编号 (11)输入 8,进入按系别编号查询界面,输入要查询的系的编号 七、参考文献【1】C+程序设计作者:

10、郑莉,董渊,张瑞丰 出版社:清华大学出版社 时间:2003/12【2】数据结构作者:严蔚敏,吴伟民 出版社:清华大学出版社 时间:2006/10【3】数据结构教程上机实验指导作者:严蔚敏,吴伟民,米宁 出版社:清华大学出版 社 时间:2006/5【4】网址:http:/ 八、附录 1、源程序#include#include#include#include#include#include#include#include typedef struct Department /系的结构 char name20;/系的名称 int number;/系的编号 int boy;/男子团体总分 int gi

11、rl;/女子团体总分 Department*next;Department;typedef struct Sport /运动项目结构 char name20;/运动项目名称 int isboy;/0 为女项目,1 为男项目 int is3;/0 为取前五名,1 为取前五名 int number;/项目编号 int first;/第一名系的编号 int second;/第二名系的编号 int third;/第三名系的编号 int fourth;/第四名系的编号 int fifth;/第五名系的编号 Sport*next;Sport;int getint(int a)/字符转换成数字 return

12、(int)(a-0);Department*head1;/-启动画面函数-void Cover()system(color 1b);char line=程序读取中 请耐心等待.;char bar=.;int i,j,k=0,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-s

13、trlen(line)/2;j+)/行坐标定位 cout;coutline;/输出线条 coutendl;for(j=0;j(65-strlen(bar)/2;j+)cout;cout(i+7)*5%Loading;cout.write(bar,k);coutendl;for(j=0;j10;j+)coutendl;for(j=0;j24;j+)cout;cout程序设计员:05 计本 4 班李涛 沈晓霖 陈秀华endl;for(j=0;j24;j+)cout;for(j=0;j=18;j+)cout;coutendl;for(j=0;j4)k=0;void department_add()/

14、添加系 Department*p;int mark=0;p=new Department;coutp-name;char c;while(mark!=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

15、(Department.txt,ios:out);outfiledepartment_getlong(p)+1;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_out

16、put(Department*p)/输出系 cout 系名 编号 男团总分 女团总分 总分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(

17、p-number=a)coutnamenext;coutnext;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,*te

18、mp1;temp1=new Department;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-girl;p-girl

19、=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;Sport*p;p=head2;p=p-next;

20、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=(int)(c-0);/字符转换成数字 if(!isdigit(c)cout数据非法isboyisboy1)c

21、out数据非法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_addmark(5,c,p-isboy);else department_addmark(7,c,p-isboy);mark=0;while(mark!=1)

22、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

23、department_addmark(3,c,p-isboy);mark=0;if(p-is3=1)while(mark!=1)coutc;if(!isdigit(c)cout数据非法endl;else if(!department_isexist(c)coutfourth=c;department_addmark(2,c,p-isboy);mark=0;while(mark!=1)coutc;if(!isdigit(c)cout数据非法endl;else if(!department_isexist(c)cout该系不存在,请先添加fifth=c;department_addmark(1,c

24、,p-isboy);else p-fourth=0;p-fifth=0;p-next=head2-next;head2-next=p;cout成功添加了一个运动项目next!=NULL)i+;first=first-next;return i;void sport_write()/将项目数据写入文本文档 Sport*p;p=head2;p=p-next;ofstream outfile(Sport.txt,ios:out);outfilesport_getlong(p)+1;while(p!=NULL)outfilename number isboy is3 first second thir

25、d fourth fifthnext;outfile.close();coutWrite Success!i;while(i0)Sport*p;p=new Sport;infilep-namep-numberp-isboyp-is3p-firstp-secondp-thirdp-fourthp-fifth;p-next=head2-next;head2-next=p;i-;coutSport Data Read Success!endl;void sport_output(Sport*p)/输出项目的情况 coutname tNum B/G 3/5 first second third fou

26、rth fifth endl;while(p)coutname t number)isboy)is3)first);department_show(p-second);department_show(p-third);department_show(p-fourth);department_show(p-fifth);/printf(n);p=p-next;coutn;coutnext;while(p)if(p-number=a)cout项目名:nameendlisboy=1)cout男子项目;else cout女子项目;coutendlfirst);coutendlsecond);coute

27、ndlthird);coutendlfourth);coutendlfifth);return;p=p-next;coutnext=NULL;head2=new Sport;head2-next=NULL;/school_add();sport_read();department_read();/sport_add();Department*p1;Sport*p2;p1=head1;p1=p1-next;p2=head2;p2=p2-next;char choose;char temp;/string ch=;int a=1;while(a!=0)coutendl;cout .oO 欢迎使用运

28、动会分数统计系统 Oo.endl;cout *endl;cout *endl;cout *1.输入系别;2.输入运动项目 *endl;cout *endl;cout *3.按系别编号输出总分;4.按总分排序;*endl;cout *endl;cout *5.按男团体总分排序;6.按女团体总分排序;*endl;cout *endl;cout *7.按项目编号查询;8.按系别编号查询;*endl;cout *endl;cout *0.退 出 *endl;cout *endl;cout *提示:需先输入系别后才能输入运动项目 *endl;cout *endl;cout *endl;coutch;/c

29、hoose=int(ch0)+int(ch1)-0;/处理异常状态 cinchoose;if(!isdigit(choose)system(cls);cout操作非法 1endl;else switch(getint(choose)case 1:system(cls);department_add();break;case 2:system(cls);cout当前项目:endl;sport_output(p2);cout当前系:endl;department_output(p1);sport_add();break;case 3:system(cls);department_output(p1

30、);break;case 4:system(cls);department_order(p1,0);department_output(p1);break;case 5:system(cls);department_order(p1,1);department_output(p1);break;case 6:system(cls);department_order(p1,2);department_output(p1);break;case 7:system(cls);couttemp;sport_search(temp);break;case 8:system(cls);couttemp;department_search(temp);break;case 0:system(cls);a=0;break;default:system(cls);cout操作非法n;department_write();sport_write();system(exit);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 应用文书 > 工作报告

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com