You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
154 lines
4.1 KiB
154 lines
4.1 KiB
include<stdio.h>
|
|
#include<math.h>
|
|
#include<stdlib.h>
|
|
#define n 2
|
|
#define m 1
|
|
#define w 1
|
|
typedef struct
|
|
{
|
|
int top;
|
|
int range[5];
|
|
int mark[5];
|
|
int itemnum;//定义项目编号
|
|
}itemnode;
|
|
typedef struct
|
|
{
|
|
int schoolnum;//学校编号
|
|
int score;//学校总分
|
|
int mscore;//男子团体提分数
|
|
int wscore;
|
|
itemnode c[m+w];//项目数量
|
|
}headnode;
|
|
headnode h[n];
|
|
void input()
|
|
{
|
|
int i,j,k,s;
|
|
for(i=0;i<n;i++)
|
|
{
|
|
h[i].schoolnum=0;
|
|
h[i].score=0;
|
|
h[i].mscore=0;
|
|
h[i].wscore=0;
|
|
}
|
|
for(i=0;i<n;i++)
|
|
{
|
|
printf("\n学 校 编 号:");
|
|
scanf("%d",&h[i].schoolnum);
|
|
for(j=0;j<m+w;j++)
|
|
{
|
|
printf("\n项 目 编 号:");
|
|
scanf("%d",&h[i].c[j].itemnum);
|
|
printf("\n取前3或前5名:");
|
|
scanf("%d",&h[i].c[j].top);
|
|
while(h[i].c[j].top!=3&&h[i].c[j].top!=5)
|
|
{printf("\n输入错误,请重新输入!:");
|
|
scanf("%d",&h[i].c[j].top);break;}
|
|
printf("\n获得名次个数:");
|
|
scanf("%d",&k);
|
|
for(s=0;s<5;s++)
|
|
h[i].c[j].range[s]=0;
|
|
for(s=0;s<k;s++)
|
|
{
|
|
l: printf("\n名 次:");
|
|
scanf("%d",&h[i].c[j].range[s]);
|
|
if(h[i].c[j].top==3)
|
|
switch(h[i].c[j].range[s])
|
|
{
|
|
case 0:h[i].c[j].mark[s]=0;
|
|
break;
|
|
case 1:h[i].c[j].mark[s]=5;
|
|
break;
|
|
case 2:h[i].c[j].mark[s]=3;
|
|
break;
|
|
case 3:h[i].c[j].mark[s]=2;
|
|
break;
|
|
default:{puts("输入错误!请重新输入!");
|
|
goto l;}
|
|
}
|
|
else
|
|
switch(h[i].c[j].range[s])
|
|
{
|
|
case 0:h[i].c[j].mark[s]=0;
|
|
break;
|
|
case 1:h[i].c[j].mark[s]=7;
|
|
break;
|
|
case 2:h[i].c[j].mark[s]=5;
|
|
break;
|
|
case 3:h[i].c[j].mark[s]=3;
|
|
break;
|
|
case 4:h[i].c[j].mark[s]=2;
|
|
break;
|
|
case 5:h[i].c[j].mark[s]=1;
|
|
break;
|
|
default:{puts("输入错误!请重新输入!");
|
|
goto l;}
|
|
}
|
|
h[i].score=h[i].score+h[i].c[j].mark[s];
|
|
if(j<=m-1)
|
|
h[i].mscore=h[i].mscore+h[i].c[j].mark[s];
|
|
else
|
|
h[i].wscore=h[i].wscore+h[i].c[j].mark[s];
|
|
}
|
|
printf("\n");
|
|
}
|
|
}
|
|
}
|
|
int main()
|
|
{ FILE *fp;
|
|
|
|
int choice;
|
|
int flag1=1,flag2=1;
|
|
system("cls");
|
|
do
|
|
{
|
|
printf("\n*************************************************************\n");
|
|
printf("\n** 运动会计分系统 **\n");
|
|
printf("\n** 1.录入信息 **\n");
|
|
printf("\n** 2.读取信息 **\n");
|
|
printf("\n** 3.显示信息 **\n");
|
|
printf("\n** 4.查询信息 **\n");
|
|
printf("\n** 5.退出程序 **\n");
|
|
printf("\n*************************************************************\n");
|
|
printf("\n\n请根据提示选择操作!:");
|
|
scanf("%d",&choice);
|
|
if(choice==1)
|
|
flag1=0;
|
|
else
|
|
if((fp=fopen("sportsdata.txt","r"))!=NULL )
|
|
flag2=0;
|
|
else
|
|
{
|
|
system("cls");
|
|
printf("没有信息,请你录入信息!\n");
|
|
}
|
|
}while(flag1&&flag2);
|
|
switch(choice)
|
|
{
|
|
case 1:
|
|
printf("\n==========请输入信息========\n");
|
|
input();
|
|
write();
|
|
printf("==========信息已存入档=========");
|
|
main();
|
|
case 2:
|
|
read();
|
|
write;
|
|
break;
|
|
case 3:
|
|
printf("===========输出信息==========\n");
|
|
if(flag1)
|
|
read();
|
|
output();
|
|
main();
|
|
case 4:
|
|
printf("===========查询信息==========\n");
|
|
if(flag1)
|
|
read();
|
|
chaxun();
|
|
main();
|
|
case 5:
|
|
printf("\n谢谢您的使用"); exit(0);
|
|
default:
|
|
printf("请根据提示输入选择操作\n"); exit(0);
|
|
}}
|