|
|
@ -93,7 +93,9 @@ l: printf("\n
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ice,i,j,t;
|
|
|
|
void output()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int choice,i,j,t;
|
|
|
|
int a[n];
|
|
|
|
int a[n];
|
|
|
|
int sign;
|
|
|
|
int sign;
|
|
|
|
do
|
|
|
|
do
|
|
|
@ -158,9 +160,157 @@ ice,i,j,t;
|
|
|
|
printf("\n");
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:for(i=0;i<n;i++)
|
|
|
|
|
|
|
|
a[i]=i;
|
|
|
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for(j=i+1;j<n;j++)
|
|
|
|
|
|
|
|
if(h[i].wscore<h[j].wscore)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t=a[i];
|
|
|
|
|
|
|
|
a[i]=a[j];
|
|
|
|
|
|
|
|
a[j]=t;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf(" 学校编号:%d \n",h[a[i]].schoolnum);
|
|
|
|
|
|
|
|
printf(" 学校总分:%d \n",h[a[i]].score);
|
|
|
|
|
|
|
|
printf(" 男团总分:%d \n",h[a[i]].mscore);
|
|
|
|
|
|
|
|
printf(" 女团总分:%d \n",h[a[i]].wscore);
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("是否继续操作(1/0)?:");
|
|
|
|
|
|
|
|
scanf("%d",&sign);
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
}while(sign==1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void chaxun()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int choice;
|
|
|
|
|
|
|
|
int i,j,k,s;
|
|
|
|
|
|
|
|
printf("\n** 1:按学校编号查询 **\n");
|
|
|
|
|
|
|
|
printf("\n** 2:按项目编号查询 **\n");
|
|
|
|
|
|
|
|
printf("\n请选择查询方式:");
|
|
|
|
|
|
|
|
scanf("%d",&choice);
|
|
|
|
|
|
|
|
switch(choice)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("请输入要查询的学校编号:");
|
|
|
|
|
|
|
|
scanf("%d",&i);
|
|
|
|
|
|
|
|
if((i>n)||(i<=0))
|
|
|
|
|
|
|
|
printf("错误:这个学校没有参加此次运动会!\n");
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("请输入要查询的项目编号:");
|
|
|
|
|
|
|
|
scanf("%d",&j);
|
|
|
|
|
|
|
|
if(j>m+w||j==0)
|
|
|
|
|
|
|
|
printf("******************此次运动会没有这个项目******************\n");
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("这个项目取前 %d名,该学校的成绩如下:\n", h[0].c[j-1].top);
|
|
|
|
|
|
|
|
for(k=0;k<5;k++)
|
|
|
|
|
|
|
|
if(h[i-1].c[j-1].range[k]!=0)
|
|
|
|
|
|
|
|
printf("名次:%d\n",h[i-1].c[j-1].range[k]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("是否继续操作(1/0)?:");
|
|
|
|
|
|
|
|
scanf("%d",&s);
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
}while(s==1);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("要查询的项目编号:");
|
|
|
|
|
|
|
|
scanf("%d",&s);
|
|
|
|
|
|
|
|
if(s>m+w||s==0)
|
|
|
|
|
|
|
|
printf("此次运动会不包括这个项目\n");
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("该项目取前 %d名,取得名次的学校\n",h[0].c[s-1].top);
|
|
|
|
|
|
|
|
for(i=0; i<n;i++)
|
|
|
|
|
|
|
|
for(j=0;j<5;j++)
|
|
|
|
|
|
|
|
if(h[i].c[s-1].range[j]!=0)
|
|
|
|
|
|
|
|
printf("学校编号:%d,名次:%d\n",h[i].schoolnum,h[i].c[s-1].range[j]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("是否继续操作(1/0)?:");
|
|
|
|
|
|
|
|
scanf("%d",&i);
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
}while(i==1);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void write()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int i,j,s;
|
|
|
|
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
if((fp=fopen("sportsdata.txt","a+"))==NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("不能打开文件\n");
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fputs("学校编号 学校总分 男子总分 女子总分 ",fp);
|
|
|
|
|
|
|
|
fputs("\n",fp);
|
|
|
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fprintf(fp,"%2d\t\t ",h[i].schoolnum);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fprintf(fp,"%2d\t\t",h[i].score);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fprintf(fp,"%2d\t\t",h[i].mscore);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fprintf(fp,"%2d ",h[i].wscore);
|
|
|
|
|
|
|
|
fputs("\n",fp);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(fclose(fp))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("不能关闭文件\n");
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void read()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
int i,j,s;
|
|
|
|
|
|
|
|
if((fp=fopen("sportsdata.txt","r"))==NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("文件不存在,不能打开文件!\n");
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fscanf(fp,"%d",&h[i].schoolnum);
|
|
|
|
|
|
|
|
for(j=0;j<m+w;j++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fscanf(fp,"%d",&h[i].c[j].itemnum);
|
|
|
|
|
|
|
|
fscanf(fp,"%d",&h[i].c[j].top);
|
|
|
|
|
|
|
|
for(s=0;s<5;s++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fscanf(fp,"%d",&h[i].c[j].range[s]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(fclose(fp))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("不能关闭文件\n");
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
int main()
|
|
|
|
int main()
|
|
|
|
{ FILE *fp;
|
|
|
|
{ FILE *fp;
|
|
|
|
|
|
|
|
system("color CF");
|
|
|
|
int choice;
|
|
|
|
int choice;
|
|
|
|
int flag1=1,flag2=1;
|
|
|
|
int flag1=1,flag2=1;
|
|
|
|
system("cls");
|
|
|
|
system("cls");
|
|
|
@ -169,10 +319,9 @@ int main()
|
|
|
|
printf("\n*************************************************************\n");
|
|
|
|
printf("\n*************************************************************\n");
|
|
|
|
printf("\n** 运动会计分系统 **\n");
|
|
|
|
printf("\n** 运动会计分系统 **\n");
|
|
|
|
printf("\n** 1.录入信息 **\n");
|
|
|
|
printf("\n** 1.录入信息 **\n");
|
|
|
|
printf("\n** 2.读取信息 **\n");
|
|
|
|
printf("\n** 2.显示信息 **\n");
|
|
|
|
printf("\n** 3.显示信息 **\n");
|
|
|
|
printf("\n** 3.查询信息 **\n");
|
|
|
|
printf("\n** 4.查询信息 **\n");
|
|
|
|
printf("\n** 4.退出程序 **\n");
|
|
|
|
printf("\n** 5.退出程序 **\n");
|
|
|
|
|
|
|
|
printf("\n*************************************************************\n");
|
|
|
|
printf("\n*************************************************************\n");
|
|
|
|
printf("\n\n请根据提示选择操作!:");
|
|
|
|
printf("\n\n请根据提示选择操作!:");
|
|
|
|
scanf("%d",&choice);
|
|
|
|
scanf("%d",&choice);
|
|
|
@ -195,23 +344,20 @@ int main()
|
|
|
|
write();
|
|
|
|
write();
|
|
|
|
printf("==========信息已存入档=========");
|
|
|
|
printf("==========信息已存入档=========");
|
|
|
|
main();
|
|
|
|
main();
|
|
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
read();
|
|
|
|
|
|
|
|
write;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
|
|
printf("===========输出信息==========\n");
|
|
|
|
printf("===========输出信息==========\n");
|
|
|
|
if(flag1)
|
|
|
|
if(flag1)
|
|
|
|
read();
|
|
|
|
read();
|
|
|
|
output();
|
|
|
|
output();
|
|
|
|
main();
|
|
|
|
main();
|
|
|
|
case 4:
|
|
|
|
case 3:
|
|
|
|
printf("===========查询信息==========\n");
|
|
|
|
printf("===========查询信息==========\n");
|
|
|
|
if(flag1)
|
|
|
|
if(flag1)
|
|
|
|
read();
|
|
|
|
read();
|
|
|
|
chaxun();
|
|
|
|
chaxun();
|
|
|
|
main();
|
|
|
|
main();
|
|
|
|
case 5:
|
|
|
|
case 4:
|
|
|
|
printf("\n谢谢您的使用"); exit(0);
|
|
|
|
printf("\n谢谢您的使用"); exit(0);
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
printf("请根据提示输入选择操作\n"); exit(0);
|
|
|
|
printf("请根据提示输入选择操作\n"); exit(0);
|
|
|
|