C语言运动会计分程序编写Word文档格式.docx

上传人:b****7 文档编号:22328815 上传时间:2023-02-03 格式:DOCX 页数:18 大小:17.76KB
下载 相关 举报
C语言运动会计分程序编写Word文档格式.docx_第1页
第1页 / 共18页
C语言运动会计分程序编写Word文档格式.docx_第2页
第2页 / 共18页
C语言运动会计分程序编写Word文档格式.docx_第3页
第3页 / 共18页
C语言运动会计分程序编写Word文档格式.docx_第4页
第4页 / 共18页
C语言运动会计分程序编写Word文档格式.docx_第5页
第5页 / 共18页
点击查看更多>>
下载资源
资源描述

C语言运动会计分程序编写Word文档格式.docx

《C语言运动会计分程序编写Word文档格式.docx》由会员分享,可在线阅读,更多相关《C语言运动会计分程序编写Word文档格式.docx(18页珍藏版)》请在冰豆网上搜索。

C语言运动会计分程序编写Word文档格式.docx

有中文提示,各学校分数为整形

  界面要求:

有合理的提示,每个功能可以设立菜单,根据提示,可以完成相关的功能要求。

  存储结构:

学生自己根据系统功能要求自己设计,但是要求运动会的相关数据要存储在数据文件中。

(数据文件的数据读写方法等相关内容在c语言程序设计的书上,请自学解决)请在最后的上交资料中指明你用到的存储结构;

测试数据:

要求使用1、全部合法数据;

2、整体非法数据;

3、局部非法数据。

进行程序测试,以保证程序的稳定。

测试数据及测试结果请在上交的资料中写明;

#include<

stdio.h>

string>

iomanip>

fstream>

usingnamespacestd;

intn,m,w;

structpro//表示项目的结构体

{

stringname;

//项目名称

intsnum[6];

//前5名学校的编号

}p[21];

structschool//表示学校的结构体

{

intnum;

//学校名称

intscore;

//学校总分

intmale;

//男子总分

intfemale;

//女子总分

}sch[21];

intintegral1[5]={7,5,3,2,1};

//前五名得分

intintegral2[3]={5,3,2};

//前三名得分

voidinput()

inti,j,y,x;

printf("

输入学校数目:

"

);

y=0;

scanf("

%d"

&

n);

if(n>

=1&

&

n<

y=1;

if(y)break;

else

printf("

输入数据有误,请重新输入:

for(i=1;

i<

=n;

i++)

{

输入第%d个学校的名称:

i);

scanf("

%s"

sch[i].name);

sch[i].score=0;

sch[i].female=0;

sch[i].male=0;

sch[i].num=i;

}

输入男子项目数和女子项目数:

%d%d"

m,&

w);

if(m<

=20&

m>

w<

w>

=1)y=1;

if(y)break;

elseprintf("

}

for(i=1;

=m+w;

printf("

输入第%d个项目的名称:

\n"

scanf("

p[i].name);

输入第%d个项目的前5名的学校编号:

for(j=1;

j<

=5;

j++)

y=0;

while

(1)

x);

if(x>

x<

=20)y=1;

p[i].snum[j]=x;

sch[x].score+=integral[j-1];

if(i<

=m)sch[x].male+=integral[j-1];

elsesch[x].female+=integral[j-1];

voidprint(inti)

%d%d%s%d%d%d%d%d%d"

sch[i].num,setw(10),sch[i].name,setw(8),sch[i].score,setw(9)

sch[i].male,setw(10),sch[i].female);

voidbianhao()//按编号排序

inti,j;

schoolt;

n;

for(j=i;

if(sch[i].num>

sch[j].num)

{t=sch[i];

sch[i]=sch[j];

sch[j]=t;

\n按编号排列:

编号学校名称总分男子总分女子总分\n"

print(i);

voidzongfen()//按学校总分排序

if(sch[i].score<

sch[j].score)

\n按学校总分排列:

ofstreamfout;

fout.open("

运动会分数统计.txt"

fout<

<

编号学校名称总分男子总分女子总分"

endl;

{fout<

sch[i].num<

setw(13)<

sch[i].name<

setw(8)<

sch[i].score<

setw(9)

sch[i].male<

setw(10)<

sch[i].female<

}

fout.close();

voidmalezf()//按学校男总分排序

if(sch[i].male<

sch[j].male)

\n按学校男子总分排列:

voidfemalezf()//按学校女总分排序

if(sch[i].female<

sch[j].female)

\n按学校女子总分排列:

voidcxsch()//查询学校信息

inti,y,s;

输入需要查询的学校编号:

s);

if(s>

s<

=n)y=1;

该学校相关信息:

if(sch[i].num==s)

break;

voidcxxm()//查询项目信息

输入需要查询的项目编号:

%s前5名学校编号及名称为\n"

p[s].name);

名次编号学校名称\n"

%d%d%d%s\n"

i,p[s].snum[i],setw(12),sch[p[s].snum[i]].name);

voidsolve()//菜单函数

intz;

\n选择您需要的操作(选择序号):

1.按学校编号排序输出\n"

2.按学校总分排序输出\n"

3.按学校男总分排序输出\n"

4.按学校女总分排序输出\n"

5.查询某个学校成绩\n"

6.查询某个项目成绩\n"

7.结束\n\n"

z);

if(z==1)bianhao();

if(z==2)zongfen();

if(z==3)malezf();

if(z==4)femalezf();

if(z==5)cxsch();

if(z==6)cxxm();

if(z==7)break;

intmain()//主函数

input();

solve();

return0;

}

intn;

//n个学校

intm;

//m个男子项目

intw;

//w个女子项目

stringname;

intsnum[6];

intnum;

intscore;

intmale;

intfemale;

intintegral[5]={7,5,3,2,1};

//前五名得分

inti,j,y,x;

if(n>

sch[i].score=0;

sch[i].female=0;

sch[i].male=0;

sch[i].num=i;

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

当前位置:首页 > 教学研究 > 教学计划

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

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