运动会分数统计程序.docx

上传人:b****3 文档编号:4007241 上传时间:2022-11-27 格式:DOCX 页数:23 大小:89.93KB
下载 相关 举报
运动会分数统计程序.docx_第1页
第1页 / 共23页
运动会分数统计程序.docx_第2页
第2页 / 共23页
运动会分数统计程序.docx_第3页
第3页 / 共23页
运动会分数统计程序.docx_第4页
第4页 / 共23页
运动会分数统计程序.docx_第5页
第5页 / 共23页
点击查看更多>>
下载资源
资源描述

运动会分数统计程序.docx

《运动会分数统计程序.docx》由会员分享,可在线阅读,更多相关《运动会分数统计程序.docx(23页珍藏版)》请在冰豆网上搜索。

运动会分数统计程序.docx

运动会分数统计程序

 

运动会分数统计系统

设计报告

院系:

专业:

班级:

姓名:

学号:

日期:

2012年5月27日星期日

运动会分数统计系统

一、实验要求:

某校要召开运动会,现要求开发一个学校运动会成绩统计系统,参加运动会有n个系,比赛分成m个男子项目,和w个女子项目。

系信息(系编号为D01……n,系名称Dname),

运动员信息:

(编号,姓名,性别,所属系,成绩(初值为0))

项目信息:

(项目编号,项目名称)

功能要求:

(1)生成报名表:

(2)维护报名表:

增加、删除、修改,(报名人数3人以下(含3人)取消该项目的比赛)

(3)登记各项比赛成绩

(4)根据预赛成绩产生预(决)赛名单

(5)计分规则:

报名人数在16人以上(含16人)取取前八名,前八名的积分分别为:

8、7、6、5、4、3、2、1;

报名人数在8人以上(含8人)16人以下,取前五名,前五名的积分分别为:

7、5、3、2、1;

报名人数在8人以下,取前三名,前三名的积分分别为:

5、3、2;

(6)统计

●能统计各系总分,

●按系系总分、男女团体总分排序输出;

按项目编号查询取得前三或前五或前八名的运动员情况。

二、设计过程:

数据结构:

名称编号男女团体

运动项目:

项目编号,名称,男子项目,女子项目,

前三名,前五名,第一名系编号,第二名系编号,第三名系编号,第四名系编号,第五名系编号。

院系类

Dname

Name

Number

Sex

classDname{//院系

private:

charname[20];

intnumber;

intboy;

intgirl;

public:

Dname*next;

voidDname_add();

voidDname_output(Dname*p);

intDname_isexist(inta);

voidDname_show(inta);

voidDname_search(inta);

voidDname_addmark(inta,intb,intc);

voidDname_order(Dname*temp,inttype);

};

 

运动项目类;

sport

name

number

排名

classSport//运动项目

{

private:

charname[20];

intisboy;//0为女项目?

1为男项目

intis3;//0为取前五名,1为取前五名

intnumber;//项目编号

intfirst;//

intsecond;//

intthird;//

intfourth;//

intfifth;//

public:

Sport*next;

intSport_isexist(inta);

voidSport_add();

voidSport_output(Sport*p);

voidSport_search(inta);

};

三、程序编码:

#include

#include

#include

usingnamespacestd;

classDname{//院系

private:

charname[20];

intnumber;

intboy;

intgirl;

public:

Dname*next;

voidDname_add();

voidDname_output(Dname*p);

intDname_isexist(inta);

voidDname_show(inta);

voidDname_search(inta);

voidDname_addmark(inta,intb,intc);

voidDname_order(Dname*temp,inttype);

};

 

classSport//运?

动¡¥项?

目?

{

private:

charname[20];

intisboy;//0为女项目1为男项目?

intis3;//为取前五名为取前五名?

intnumber;//项?

目?

编À¨¤号?

intfirst;//

intsecond;//

intthird;//

intfourth;//

intfifth;//

public:

Sport*next;

intSport_isexist(inta);

voidSport_add();

voidSport_output(Sport*p);

voidSport_search(inta);

};

 

Dname*head1;

Sport*head2;

 

voidDname:

:

Dname_add()

{

Dname*p;

intmark=0;

p=newDname;

cout<<"请输入院系的名称:

";

cin>>p->name;

intc;

while(mark!

=1)

{

cout<<"请输入院系编号:

";

cin>>c;

p->number=c;

mark=1;

p->boy=0;

p->girl=0;

p->next=head1->next;

head1->next=p;

cout<<"成功添加了一个院系"<

cout<<"是否还要添加院¦y/n)"<

charinput,y,n;

cin>>input;

switch(input)

{

case'y':

mark=0;

Dname_add();

case'n':

mark=1;

return;

}

}

deletep;

}

 

voidDname:

:

Dname_output(Dname*p){//输出系

cout<<"当前院系(名称)编号男团总分女团总分 总分t\n";

p=head1;

p=p->next;

while(p){

cout<name<<"\t\t"<number<<"\t"<boy<<"\t"<girl<<"\t"<<(p->girl+p->boy)<

p=p->next;

}

}

 

intDname:

:

Dname_isexist(inta)

{

intb=0;

Dname*p;

p=head1;

p=p->next;

while(p)

{

if(p->number==a)

{

return1;

}

p=p->next;

}

return0;

}

 

voidDname:

:

Dname_show(inta)//输出所有院系

{

Dname*p;

p=head1;

p=p->next;

while(p)

{

if(p->number==a)

{

cout<name<<" ?

"<

return;

}

p=p->next;

}

cout<<"无T";

}

 

voidDname:

:

Dname_search(inta)

{

Dname*p;

p=head1;

p=p->next;

while(p)

{

if(p->number==a)

{

cout<<"院系名称:

"<name<<""<<"男子团体总分:

"<boy<<""

<<"女子团体总分:

"<girl<<""<<"总分:

"<<(p->boy+p->girl)<<"";

return;

}

p=p->next;

}

cout<<"无T此ä?

编À¨¤号?

:

"<

}

 

voidDname:

:

Dname_addmark(inta,intb,intc)女?

{

Dname*p;

p=head1;

p=p->next;

while(p)

{

if(p->number==b)

{

if(c==1)

{

p->boy=p->boy+a;

}

else

{

p->girl=p->girl+a;

}

}

p=p->next;

}

}

voidDname:

:

Dname_order(Dname*temp,inttype)

{

Dname*q,*small;

Dname*temp1;

temp1=newDname;

temp1->next=NULL;

while(q&&small)

{

switch(type)

{

case0:

//按总分排序

for(q=head1;q=q->next;q!

=NULL)

for(small=head1;small=small->next;small!

=NULL)

{

if((q->boy+q->girl)<(small->boy+small->girl))

{

temp1->girl=q->girl;

q->girl=small->girl;

small->girl=temp1->girl;

temp1->boy=q->boy;

q->boy=small->boy;

small->boy=temp1->boy;

strcpy(temp1->name,q->name);

strcpy(q->name,small->name);

strcpy(small->name,temp1->name);

temp1->number=q->number;

q->number=small->number;

small->number=temp1->number;//

}

}

break;

case1:

//按男团体排序

for(q=head1;q=q->next;q!

=NULL)

for(small=head1;small=small->next;small!

=NULL)

{

if(q->boyboy)

{

temp1->girl=q->girl;

q->girl=small->girl;

small->girl=temp1->girl;

temp1->boy=q->boy;

q->boy=small->boy;

small->boy=temp1->boy;

strcpy(temp1->name,q->name);

strcpy(q->name,small->name);

strcpy(small->name,temp1->name);

temp1->number=q->number;

q->number=small->number;

small->number=temp1->number;//

}

}

break;

case2:

for(q=head1;q=q->next;q!

=NULL)

for(small=head1;small=small->next;small!

=NULL)

{

if(q->girlgirl)

{

temp1->girl=q->girl;

q->girl=small->girl;

small->girl=temp1->girl;

temp1->boy=q->boy;

q->boy=small->boy;

small->boy=temp1->boy;

strcpy(temp1->name,q->name);

strcpy(q->name,small->name);

strcpy(small->name,temp1->name);

temp1->number=q->number;

q->number=small->number;

small->number=temp1->number;//

}

}

break;

case3:

for(q=head1;q=q->next;q!

=NULL)

for(small=head1;small=small->next;small!

=NULL)

{

if(q->numbernumber)

{

temp1->girl=q->girl;

q->girl=small->girl;

small->girl=temp1->girl;

temp1->boy=q->boy;

q->boy=small->boy;

small->boy=temp1->boy;

strcpy(temp1->name,q->name);

strcpy(q->name,small->name);

strcpy(small->name,temp1->name);

temp1->number=q->number;

q->number=small->number;

small->number=temp1->number;//

}

}

break;

default:

cout<<"error"<

break;

}

}

}

 

intSport:

:

Sport_isexist(inta)

{

intb=0;

Sport*p;

p=head2;

while(p)

{

if(p->number==a)

{

return1;

}

p=p->next;

}

return0;

voidSport:

:

Sport_add()

{

Sport*p;

//Dnamesh;

intmark=0;

p=newSport;

cout<<"请?

输º?

入¨?

项?

目?

名?

称?

:

";

cin>>p->name;

intc;

while(mark!

=1)

{

cout<<"请?

输º?

入¨?

项?

目?

编À¨¤号?

:

";

cin>>c;

if(Sport_isexist(c))

{

cout<<"该?

编À¨¤号?

已°?

存ä?

在¨²!

";

}

else

{

mark=1;

p->number=c;

}

}

mark=0;

while(mark!

=1)

{

cout<<"请?

输º?

入¨?

项?

目?

类¤¨¤型¨ª(0为a女?

子Á¨®项?

目?

1为a男D子Á¨®项?

目?

):

";

cin>>c;

//p->isboy=(int)(c-'0');//去¨£¤掉Ì?

了¢?

字Á?

符¤?

转Áa换?

成¨¦数ºy字Á?

mark=1;

p->isboy=c;

}

mark=0;

while(mark!

=1)

{

cout<<"请输入项目名称情况(0为取前3名,1为取前5名):

";

cin>>c;

//p->is3=(int)(c-'0');

mark=1;

p->is3=c;

}

mark=0;

Dnamesh;

while(mark!

=1)

{

cout<<"请输入第一名院系的编号:

";

cin>>c;

if(!

sh.Dname_isexist(c))

{

cout<<"该院系不存在请先添加!

";

}

else

{

mark=1;

p->first=c;

if(p->is3=='0')

sh.Dname_addmark(5,c,p->isboy);

else

sh.Dname_addmark(7,c,p->isboy);

}

}

mark=0;

while(mark!

=1)

{

cout<<"请输入第二名院系的编号?

:

";

cin>>c;

if(!

sh.Dname_isexist(c))

{

cout<<"该院系不存在请先添加!

";

}

else

{

mark=1;

p->second=c;

if(p->is3=='0')

sh.Dname_addmark(3,c,p->isboy);

else

sh.Dname_addmark(5,c,p->isboy);

}

}

mark=0;

while(mark!

=1)

{

cout<<"请输入第三名院系的编号:

";

cin>>c;

if(!

sh.Dname_isexist(c))

{

cout<<"该院系不存在请先添加";

}

else

{

mark=1;

p->third=c;

if(p->is3=='0')

sh.Dname_addmark(2,c,p->isboy);

else

sh.Dname_addmark(3,c,p->isboy);

}

}

mark=0;

if(p->is3=='1')

{

while(mark!

=1)

{

cout<<"请输入第四名院系的编号:

";

cin>>c;

if(!

sh.Dname_isexist(c))

{

cout<<"该院系不存在请先添加";

}

else

{

mark=1;

p->fourth=c;

sh.Dname_addmark(2,c,p->isboy);

}

}

mark=0;

while(mark!

=1)

{

cout<<"请输入第五名院系的编号:

";

if(!

sh.Dname_isexist(c))

{

cout<<"该院系不存在请先添加!

";

}

else

{

mark=1;

p->fifth=c;

sh.Dname_addmark(1,c,p->isboy);

}

}

}

else

{

p->fourth='0';

p->fifth='0';

}

p->next=head2->next;

head2->next=p;

cout<<"成功添加了一个运动项目"<

}

 

voidSport:

:

Sport_output(Sport*p)//输º?

出?

项?

目?

的Ì?

情¨¦况?

{

p=head2;

p=p->next;

cout<<"当前项目名称"<<"\t"<<"编号?

"<<" "<<"B/G"<<" "<<"3/5"<<""<<"第一名"<<" "

<<"第二名"<<""<<"第三名"<<""<<"第四名"<<""<<"第五名"<<""<

Dnamesh;

while(p)

{

cout<name<<"\t"<<""<number<<" "<isboy<<""<is3<<""

<<"";

sh.Dname_show(p->first);

sh.Dname_show(p->second);

sh.Dname_show(p->third);

sh.Dname_show(p->fourth);

sh.Dname_show(p->fifth);

p=p->next;

cout<<"\n";

}

cout<

}

 

voidSport:

:

Sport_search(inta)//搜?

索¡Â项?

目?

{

Sport*p;

Dnamesh;

p=head2;

p=p->next;

while(p)

{

if(p->number==a)

{

cout<<"项目名:

"<name<

";

if(p->isboy==1)

{

cout<<"男子项目";

}

else

{

cout<<"女子项目";

}

cout<

";

sh.Dname_show(p->first);

cout<

";

sh.Dname_show(p->second);

cout<

";

sh.Dname_show(p->third);

cout<

";

sh.Dname_show(p->fourth);

cout<

名?

:

";

sh.Dname_show(p->fifth);

return;

}

p=p->next;

}

cout<<"无此编号";

}

 

voidmain(){//运动会程序主函数

system("colorC");//改变背景前景色

head1=newDname;

head1->next=NULL;

head2=newSport;

head2->next=NULL;

//Dname_add();

Dnamesh;

Sportsp;

Dname*p1;

Sport*p2;

p1=head1;

p1=p1->next;

p2=head2;

p2=p2->next;

intchoose;

chartemp;

inta=1;

while(a!

=0)

{

cout<<""<

cout<<"欢迎使用运动会分数统计系统"<

cout<<"----------------------------------------------------------"<

cout<<""<

cout<<"1.输入院系;2.输入运动项目"<

cout<<"3.按院系编号输出总分;4.按院系总分排序;"<

cout<<"5.按男团体总分排序;6.按女团体总分排序;"<

cout<<"7.按院系编号查询;8.按项目编号查询;"<

cout<<"0.退出"<

cout<<"注输入运动项目之前请输入院系"<

cout<<"----------------------------------------------------------"<

cout<<"-------请选择(0-8):

------"<

cin>>choose;

switch(choose)

{

case1:

sh.Dname_add();

break;

case

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 能源化工

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

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