ImageVerifierCode 换一换
格式:DOCX , 页数:35 ,大小:106.70KB ,
资源ID:28264823      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/28264823.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(运动会统计问题.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

运动会统计问题.docx

1、运动会统计问题目 录1 前言 12 需求分析 22.1 问题描述 22.2 基本要求 22.3 测试数据 23 概要设计 23.1 算法设计思想 23.2 数据结构 23.3 系统流程图 34 具体代码实现 45 课程设计总结 205.1 程序运行结果 205.2 课程设计体会 20参考文献 22致 谢 22前言本学期开设的C语言程序设计课程已经告一段落。在学习科目的第一天开始,老师就为我们阐述了它的重要性。它对我们来说具有一定难度。它是其他编程语言的一门基本学科。尽管不好学,但是我们必须学好这门课程,这对于我们计算机专业的学生来说意义重大。经过一个学期的理论知识的学习,对于数据结构相关的知识

2、有了一定的了解。这是一门纯属于设计的科目,它需要把理论变为上机调试和具体实践。在课程介绍之后,老师为我们安排了这次为期两周的课程设计。目的就是让我们自己在计算机上自己设计算法来实现相应的功能以及锻炼学生的动手能力和实践能力,最重要的是要把我们所学的数据结构的理论知识应用到实践中去。这次课程设计的题目是:运功会成绩统计,要求学生自己查阅相关资料,完成相应的任务,自己上机设计算法,调试程序,运行出结果,以此来加深理解线性表、查找表的逻辑结构、存储结构,掌握查找、排序登记本运算的实现,进一步理解和熟练掌握课本中所学的各种书本中所学的各种数据结构,学会把学到的知识用于解决实际问题,培养自己的动手能力。

3、2 需求分析2.1 问题描述参加运动会有n个系,系编号为1n。比赛分成m个男子项目,和w个女子项目。项目编号为男子1m,女子m+1m+w。不同的项目取前五名或前三名积分;取前五名的积分分别为:7、5、3、2、1,前三名的积分分别为:5、3、2;哪些取前五名或前三名由学生自己设定。(m=20,n=20)2.2 基本要求(1).可以输入各个项目的前三名或前五名的成绩;(2)能统计各系总分;(3)可以按系编号、系总分、男女团体总分排序输出;(4).可以按系编号查询系某个项目的情况;可以按项目编号查询取得前三或前五名的系。2.3 测试数据(1)输入:1进入添加系的界面,根据提示,再输入相应的信息:,成

4、功添加了一个系。再输入:2进入运动项目添加界面,根据提示,再输入:跳高;1;0;1;2;3。之后输入0。再次进入系统界面。(2)输入:3查看输出结果。(3):输入:4查看输出结果。(4):输入:5查看输出结果。(5):输入:6查看输出结果。(6):输入:7根据提示输入项目编号:2。查看输出结果。 (7):输入:8根据提示输入系编号:3。查看输出结果3 概要设计3.1 算法设计思想 本程序主要是使用链表来实现操作。一个运动会包括运动项目和参加运动会的成员。因此构造两个链表Department,Sport。为了操作的方便,并且能够保存输入数据,所以通过文件操作来实现数据的写和读。每次添加新的数据后

5、都要输入0退出,数据才能保存。对于总分的排序使用了冒泡排序。为了使整个程序看起来更加友好,又添加了程序启动画面。 3.2 数据结构 (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为男项目 int is3; /0

6、为取前五名,1为取前五名 int number; /项目编号 int first; /第一名系的编号 int second; /第二名系的编号 int third; /第三名系的编号 int fourth; /第四名系的编号 int fifth; /第五名系的编号 Sport *next;Sport;3.3 系统流程图图3.1 主模块流程图4 具体代码实现#include#include#include#include#include#include#include#includetypedef struct Department /系的结构 char name20; /系的名称 int nu

7、mber; /系的编号 int boy; /男子团体总分 int girl; /女子团体总分 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

8、*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,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=

9、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 ; cout(i+7)*5% Loading; cout.write(bar,k); coutendl; for(j=0;j10;j+) coutendl; for(j=0;j24;j+) cout ; cout程序设计员:10计本李艳红endl; for(j=0;j24;j+)

10、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!=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=f

11、irst-next; return i;void department_write()/将系数据写入文本 Department * p; p=head1; p=p-next; ofstream outfile(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; infile

12、p-namep-numberp-boyp-girl; p-next=head1-next; head1-next=p; i-; coutDepartment Data Read Success!endl;void department_output(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;

13、 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; 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+

14、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 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; brea

15、k; 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=small-girl; small-girl=temp1-girl; strcpy(temp1-name,p-name); strcpy(p-name,small-name); strcpy(small-name,temp1-name); temp1-nu

16、mber=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; while(p) if(p-number=a) return 1; p=p-next; return 0;void sport_add() /添加项目 Sport * p; int mark=0; p=new Sport;

17、 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) cout数据非法isboy=c; mark=0; while (mark!=1) coutc; p-is3=(int)(c-0); if (!isdigit(c) cou

18、t数据非法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) coutc; if (!isdigit(c) cout数据非法endl; else if(!department_is

19、exist(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

20、; 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,p-isboy); else p-

21、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 third fourth fifthnext; outfile.close(); coutWrite Success!i; while(i0) Sport * p; p=new Sport; infilep-namep-nu

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1