C语言课程设计报告运动会分数统计系统Word文档格式.docx
《C语言课程设计报告运动会分数统计系统Word文档格式.docx》由会员分享,可在线阅读,更多相关《C语言课程设计报告运动会分数统计系统Word文档格式.docx(38页珍藏版)》请在冰点文库上搜索。
<
1>
系:
名称,编号,男子团体总分,女子固体总分。
2>
运动项目:
项目编号,名称,男子项目,女子项目,前三名,前五名,第一名系的编号,第二名系的编号,第三名系的编号,第四名系的编号,第五名系的编号。
2.程序模块及之间的调用关系
三、详细设计
1、数据类型定义
(1)系的定义:
typedefstructDepartment//系的结构
{
charname[20];
//系的名称
intnumber;
//系的编号
intboy;
//男子团体总分
intgirl;
//女子团体总分
Department*next;
}Department;
(2)运动项目定义:
typedefstructSport//运动项目结构
//运动项目名称
intisboy;
//0为女项目,1为男项目
intis3;
//0为取前五名,1为取前五名
intnumber;
//项目编号
intfirst;
//第一名系的编号
intsecond;
//第二名系的编号
intthird;
//第三名系的编号
intfourth;
//第四名系的编号
intfifth;
//第五名系的编号
Sport*next;
}Sport;
、
2、函数之间的调用关系
(1)系调用图
department_add
department_Order
<
Departmentdepartment_search
department_addmark
department_show
department_isexist
department_output
department_read
department_write
department_getlong
sport_isexist
sport_add
sport_getlong
sport_write
Sportsport_read
sport_output
sport_search
3、算法设计
主要算法的设计思想:
本程序主要是使用链表来实现操作。
一个运动会包括运动项目和参加运动会的成员。
因此构造两个链表Department,Sport。
为了操作的方便,并且能够保存输入数据,所以通过文件操作来实现数据的写和读。
每次添加新的数据后都要输入0退出,数据才能保存。
对于总分的排序使用了冒泡排序。
为了使整个程序看起来更加友好,又添加了程序启动画面。
四、调试分析
本程序相对来说比较容易看明白,其中涉及到的一些函数相对来说比较容易。
通过调试,运行,基本上达到了要求,但还存在一些缺点。
如:
不够人性化等。
五、测试结果
多组数据输入与输出:
(1)输入:
3
输出:
系名编号男团总分女团总分总分
法律系6000
电子系5325
数学系4606
历史系39716
中文系2151126
计算机系1211132
旅游系7077
(2)输入:
4
系名编号男团总分女团总分总分
旅游系7077
(3)输入:
5
输出:
法律系6000
(4)输入:
6
输出:
(5)输入:
7
请输入项目编号:
输入:
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.按系别编号查询
0.退出
(2)输入0~8中的一个数
(3)输入1,进行添加系操作,分别输入系的名称和编号
(4)输入2,进行添加运动项目操作,分别输入项目名称,编号,项目类型,名次选
取,排名情况
(5)输入0,则退出系统,并且保存输入的信息.每次添加完都要输入0退出系统
才有效
(6)输入3,输出按系编号总分排名.
(7)输入4,输出按总分排名
(8)输入5,输出按男团体总分排序
(9)输入6,输出按女团体总分排序
(10)输入7,进入按项目编号查询界面.输入要查询的项目编号
(11)输入8,进入按系别编号查询界面,输入要查询的系的编号
七、参考文献
【1】《C++程序设计》作者:
郑莉,董渊,张瑞丰出版社:
清华大学出版社时间:
2003/12
【2】《数据结构》作者:
严蔚敏,吴伟民出版社:
2006/10
【3】《数据结构教程上机实验指导》作者:
严蔚敏,吴伟民,米宁出版社:
清华大学出版
社时间:
2006/5
【4】网址:
八、附录
1、源程序
#include<
iostream.h>
iomanip.h>
string.h>
fstream.h>
stdlib.h>
ctype.h>
stdio.h>
conio.h>
charname[20];
intnumber;
intboy;
intgirl;
Department*next;
intisboy;
intis3;
intfirst;
intsecond;
intthird;
intfourth;
intfifth;
Sport*next;
intgetint(inta)//字符转换成数字
return(int)(a-'
0'
);
}
Department*head1;
//-------启动画面函数----------
voidCover()
{system("
color1b"
charline[]={"
程序读取中 请耐心等待..."
};
charbar[]={"
...."
inti,j,k=0,x=0,y=0;
for(i=0;
i<
=strlen(line)/2;
)
{
system("
cls"
for(j=0;
j<
9;
j++)//改变行坐标
cout<
endl;
(75-strlen(line))/2;
j++)//改变列坐标
"
"
;
for(j=1;
=i;
j++)//进度显示器
●"
for(x=strlen(line)/2;
x>
i;
x--)
○"
if(k==4)
i++;
j++)//行坐标定位
line;
//输出线条
(65-strlen(bar))/2;
j++)
(i+7)*5<
%Loading"
cout.write(bar,k);
10;
24;
程序设计员石行"
=18;
─"
j++);
//延时效果
k++;
if(k>
4)
k=0;
}
voiddepartment_add()//添加系
Department*p;
intmark=0;
p=newDepartment;
请输入系的名称:
cin>
>
p->
name;
charc;
while(mark!
=1)
请输入系的编号:
c;
if(!
isdigit(c))//是否为数字
数据非法"
else
mark=1;
p->
number=c;
boy=0;
girl=0;
next=head1->
next;
head1->
next=p;
成功添加了一个系"
intdepartment_getlong(Department*first)//得到链表长度
inti=0;
while(first->
next!
=NULL)
first=first->
returni;
voiddepartment_write()//将系数据写入文本
p=head1;
p=p->
ofstreamoutfile("
Department.txt"
ios:
:
out);
outfile<
department_getlong(p)+1<
while(p!
name<
number<
boy<
girl<
outfile.close();
WriteSuccess!
voiddepartment_read()//从文本读入系数据
inti;
ifstreaminfile("
in);
infile>
while(i>
0)
name>
number>
boy>
girl;
i--;
DepartmentDataReadSuccess!
voiddepartment_output(Department*p)//输出系
系名 编号 男团总分 女团总分 总分\t\n"
while(p)
\t"
getint(p->
number)<
\t"
\t"
(p->
girl+p->
boy)<
intdepartment_isexist(inta)//检验系是否存在
intb=0;
Department*p;
if(p->
number==a)
return1;
return0;
voiddepartment_show(inta)//输出所有系
"
return;
无 "
voiddepartment_search(inta)//按编号搜索系
系名:
男子团体总分:
女子团体总分:
总分:
boy+p->
girl)<
无此编号"
voiddepartment_addmark(inta,intb,intc)//a为分数,b为系编号,c=1表示男,c=0表示女
number==b)
if(c=='
1'
boy=p->
boy+a;
girl=p->
girl+a;
voiddepartment_order(Department*temp,inttype)//type=0按总分,type=1按男总分,type=2按女总分,
Department*p,*q,*small,*temp1;
temp1=newDepartment;
temp1->
next=NULL;
p=temp;
while(p)
small=p;
q=p->
while(q)
switch(type)
case0:
if((q->
boy+q->
(small->
girl+small->
boy))
small=q;
break;
case1:
if(q->
small->
boy)
case2:
girl)
default:
error"
if(small!
=p)
boy;
boy=small->
small->
boy=temp1->
girl=small->
girl=temp1->
strcpy(temp1->
name,p->
name);
strcpy(p->
name,small->
strcpy(small->
name,temp1->
number=p->
number;
number=small->
number=temp1->
//将系的名字互换
q=q->
Sport*head2;
intsport_isexist(inta)//检查运动项目(编号)是否已经存在
Sport*p;
p=head2;
voidsport_add()//添加项目
Sport*p;
p=newSport;
请输入项目名称:
请输入项目编号:
isdigit(c))
if(sport_isexist(c))
该编号已存在"
mark=0;
请输入项目类型(0为女子项目,1为男子项目):
isboy=(int)(c-'
//字符转换成数字
elseif(p->
isboy<
0||p->
isboy>
1)
isboy=c;
请输入项目名次情况(0为取前3名,1为取前5名):
is3=(int)(c-'
is3<
is3>
is3=c;
请输入第一名的系的编号:
if(!
department_isexist(c))
该系不存在,请先添加"
first=c;
is3=='
department_addmark(5,c,p->
isboy);
department_addmark(7,c,p->
}
请输入第二名的系的编号:
second=c;
department_addmark(3,c,p->
请输入第三名的系的编号:
third=c;
department_addmark(2,c,p->
请输入第四名的系