搜档网
当前位置:搜档网 › 运动会分数统计系统java

运动会分数统计系统java

#include
#include
#include
#include
#include
#include
#include

using namespace std;
int n; //n个学校
int m; //m个男子项目
int w; //w个女子项目
struct pro //表示项目的结构体
{
int z;
string name; //项目名称
int snum1[4]; //前3名学校的编号
int snum[6]; //前5名学校的编号
}p[21];
struct school //表示学校的结构体
{
int num;
string name; //学校名称
int score; //学校总分
int male; //男子总分
int female; //女子总分
}sch[21];

int a[101][101];
int integer[3]={5,3,2};
int integral[5]={7,5,3,2,1}; //评分标准设置
void input() //录入信息
{
int i,j,y,x;
printf("*******************************************************\n");
printf("\n\t\t【Kunzaier】运动会成绩管理系统\n");
printf("\n请输入学校数目(5<=n<=20):\n");
y=0;
while(1)
{
scanf("%d",&n);
if(n>=5&&n<=20)
y=1;
if(y)
break;
else
printf("输入数据有误,请重新输入:\n");
}
for(i=1;i<=n;i++)
{

printf("输入第%d个学校的名称:\n",i);
cin>>sch[i].name;
sch[i].score=0;
sch[i].female=0;
sch[i].male=0;
sch[i].num=i;
}
printf("输入男子项目数[1_20]和女子项目数[1_20]:\n");
y=0;
while(1)
{
scanf("%d%d",&m,&w);
if(m<=20&&m>=1&&w<=20&&w>=1)
y=1;
if(y)
break;
else
printf("输入数据有误,请重新输入:\n");
}
for(i=1;i<=m+w;i++)
{
printf("输入第%d项目个的名称:\n",i);
scanf("%s",&p[i].name);
printf("请选择该项目设立的奖项数(3或5项):\n");
y=0;
while(1)
{
scanf("%d",&p[i].z);
if(p[i].z==3||p[i].z==5)
y=1;
if(y)
break;
else
printf("输入数据有误,请重新输入:\n");
}
printf("输入第%d个项目的前%d名的学校编号:\n",i,p[i].z);
for(j=1;j<=p[i].z;j++)
{
y=0;
while(1)
{
scanf("%d",&x);
if(x>=1&&x<=n)
y=1;
if(y)
break;
else
printf("输入数据有误,请重新输入:\n");
}

if(p[i].z==3)
{
p[i].snum1[j]=x;
sch[x].score+=integer[j-1];
if(i<=m)
sch[x].male+=integer[j-1];
else
sch[x].female+=integer[j-1];
}
else
{
p[i].snum[j]=x;
sch[x].score+=integral[j-1];
if(i<=m)
sch[x].male+=integral[j-1];
else
sch[x].female+=integral[j-1];

}
}
}
ofstream outfile1("f:\\运动会分数总分表.txt",ios::out);
if(! outfile1)
{
cerr<<"open error!"<
}
outfile1<<"编号 学校名称 总分 男子总分 女子总分\n"<for(i=1;i<=n;i++)//i<=sch[i]
outfile1<<outfile1.close();

}
void print(int i)
{

cout<<}

//按编号排序
void bianhao()
{
int i,j;
school t;
for(i=1;i{
for(j=i;j<=n;j++)
if(sch[i].num>sch[j].num)
{
t=sch[i];sch[i]=sch[j];sch[j]=t;
}
}
printf("\n按编号排列:\n");
printf("编号 学校名称 总分 男子总分 女子总分\n");
for(i=1;i<=n;i++)
print(i);
}

//总分函数
void zongfentongji() //按学校总分排序
{
int i,j;
school t;
for(i=1;i{
for(j=i;j<=n;j++)
if(sch[i].score{
t=sch[i];sch[i]=sch[j];sch[j]=t;
}
}
printf("\n按学校总分排列:\n");
printf("编号 学校名称 总分 男子总分 女子总分\n");
for(i=1;i<=n;i++)
cout<<}

//按学校男总分排序
void malezongfen()
{
int i,j;
school t;
for(i=1;i{
for(j=i;j<=n;j++)
if(sch[i].male{
t=sch[i];sch[i]=sch[j];sch[j]=t;
}
}
printf("\n按学校男子总分排列:\n");
printf("编号 学校名称 总分 男子总分 女子总分\n");
for(i=1;i<=n;i++)
print(i);
ofstream outfile1("f:\\运动会男子总分排序表.txt",ios::out);
if(! outfile1)
{
cerr<<"open error!"<
}
outfile1<<"编号 学校名称 总分 男子总分 女子总分\n"<for(i=1;i<=n;i++)//i<=sch[i]
outfile1<<outfile1.close();
}

//按学校女总分排序
void femalezongfen()
{
int i,j;
school t;
for(i=1;i{
for(j=i;j<=n;j++)
if(sch[i].female{
t=sch[i];sch[i]=sch[j];sch[j]=t;
}
}
printf("\n按学校女子总分排列:\n");
printf("\n编号 学校名称 总分 男子总分 女子总分\n");
for(i=1;i<=n;i++)
print(i);
printf("\n");
ofstream outfile1("f:\\运动会女

子总分排序表.txt",ios::out);
if(! outfile1)
{
cerr<<"open error!"<
}
outfile1<<"编号 学校名称 总分 男子总分 女子总分\n"<for(i=1;i<=n;i++)//i<=sch[i]
outfile1<<outfile1.close();
}

//查询学校信息
void chaxunsch()
{
int i,y,s;
printf("输入需要查询的学校编号:\n");
y=0;
while(1)
{
scanf("%d",&s);
if(s>=1&&s<=n)
y=1;
if(y)
break;
else
printf("输入数据有误,请重新输入:");
}
printf("该学校相关信息:\n");
printf("\n编号 学校名称 总分 男子总分 女子总分\n");
for(i=1;i<=n;i++)
{
if(sch[i].num==s)
{
print(i);
break;
}
}
cout<}

//查询项目信息
void chaxunxiangmu()
{
int i,y,s;
printf("输入需要查询的项目编号:\n");
y=0;
while(1)
{
scanf("%d",&s);
if(s>=1&&s<=m+w)
y=1;
if(y)
break;
else
printf("输入数据有误,请重新输入:");
}
if(p[s].z==3)
{
printf("前3名学校编号及名称为:\n");
printf("名次\t 编号\t 学校名称\n");
for(i=1;i<=3;i++)
cout<cout<}
else
{
printf("前5名学校编号及名称为:\n");
printf("名次\t 编号\t 学校名称\n");
for(i=1;i<=5;i++)
cout<cout<}
}



//程序结束显示系统
void Thank()
{
int i;
char *thank1[]={"谢","谢","使","用"};
for(i=0;i<4;i++)
{
printf("%s",thank1[i]);
Sleep(300);
}
char *thank2[]={"【","K","u","n","z","a","i","e","r","】"};
for(i=0;i<10;i++)
{
printf("%s",thank2[i]);
Sleep(100);
}
char *thank3[]={"运","动","会","成","绩","管","理","系","统"};
for(i=0;i<9;i++)
{
printf("%s",thank3[i]);
Sleep(300);
}
printf("\n");
char *thank4[]={"B","y","e","--","B","y","e","^_^"};
for(i=0;i<8;i++)
{
printf("%s",thank4[i]);
Sleep(100);
}
cout<Sleep(500);

}


//菜单面板
void menu()
{
printf("*****欢迎使用【Kunzaier】运动会成绩管理系统*****\n");
printf("\t┌—————————————┐\n");
printf("\t│ 1.按学校编号排序输出 │\n");
printf("\t├—————————————┤\n");
printf("\t│ 2.按学校总分排序输出 │\n");
printf("\t├—————————————┤\n");
printf("\t│ 3.按学校男生总分排序输出 │\n");
printf("\t├————————————

—┤\n");
printf("\t│ 4.按学校女生总分排序输出 │\n");
printf("\t├—————————————┤\n");
printf("\t│ 5.查询某个学校成绩 │\n");
printf("\t├—————————————┤\n");
printf("\t│ 6.查询某个项目成绩 │\n");
printf("\t├—————————————┤\n");
printf("\t│ 7.退出程序 │\n");
printf("\t└—————————————┘\n");
printf("选择您需要的操作(选择序号):\n");
}

// 主函数
void main()
{
char s[5];
const M=30;
int i,k;
printf("【程序装载中 ");
for (i=1;i<=M;i++)
{
printf("■");
Sleep(100);
}
printf("】");
printf("\r");
system("cls"); //清屏
printf("【载入完成】\a\n");
printf("→ 欢迎使用【Kunzaier】运动会成绩管理系统,本程序可正常使用,部分功能完善中...\n\n");
Sleep(600);
system("pause");
system("cls");
fflush(stdin);
input();
menu();
char choose;
bool flag;
while(flag)
{
choose=getchar();
switch(choose)
{
case '1':
system("cls");
printf("你选择的是按学校编号排序输出功能!\n");
system("pause");
system("cls");
bianhao();
system("pause");
system("cls");
menu();
getchar();
break;
case '2':
system("cls");
printf("你选择的是按学校总分排序输出功能!\n");
system("pause");
system("cls");
zongfentongji();
system("pause");
system("cls");
menu();
getchar();
break;
case '3':
system("cls");
printf("你选择的是按学校男生总分排序输出功能!\n");
system("pause");
system("cls");
malezongfen();
system("pause");
system("cls");
menu();
getchar();
break;
case '4':
system("cls");
printf("你选择的是按学校女生总分排序输出功能!\n");
system("pause");
system("cls");
femalezongfen();
system("pause");
system("cls");
menu();
getchar();
break;
case '5':
system("cls");
printf("你选择的是查询某个学校成绩!\n");
system("pause");
system("cls");
chaxunsch();
system("pause");
system("cls");
menu();
getchar();
break;
case '6':
system("cls");
printf("你选择的是查询某个项目成绩!\n");
system("pause");
system("cls");
chaxunxiangmu();
system("pause");
system("cls");
menu();
getchar();
break;
case '7':
char s1[5]={'n'};
system("cls");
printf("你确定要退出系统?Y/N:\n");
scanf("%s",s);

if(strcmp(s,s1))
{
system("cls");
Thank();
Sleep(500);
exit(0);
}
else
{
system("cls");
menu();
getchar();
}
}
}
}

相关主题