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.

365 lines
11 KiB

6 years ago
#include<stdio.h>
6 years ago
#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;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
}itemnode;
typedef struct
{
int schoolnum;//ѧУ<D1A7><D0A3><EFBFBD><EFBFBD>
int score;//ѧУ<D1A7>ܷ<EFBFBD>
int mscore;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int wscore;
itemnode c[m+w];//<2F><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
}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ѧ У <20><> <20><>:");
scanf("%d",&h[i].schoolnum);
for(j=0;j<m+w;j++)
{
printf("\n<EFBFBD><EFBFBD> Ŀ <20><> <20><>:");
scanf("%d",&h[i].c[j].itemnum);
printf("\nȡǰ3<EFBFBD><EFBFBD>ǰ5<EFBFBD><EFBFBD>:");
scanf("%d",&h[i].c[j].top);
while(h[i].c[j].top!=3&&h[i].c[j].top!=5)
{printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룡:");
scanf("%d",&h[i].c[j].top);break;}
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>θ<EFBFBD><EFBFBD><EFBFBD>:");
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<EFBFBD><EFBFBD> <20><>:");
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("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!<21><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
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("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!<21><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
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");
}
}
}
6 years ago
void output()
{
int choice,i,j,t;
6 years ago
int a[n];
int sign;
do
{
printf("\n** 1.<2E><>ѧУ<D1A7><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> **\n");
printf("** 2.<2E><>ѧУ<D1A7>ܷ<EFBFBD><DCB7><EFBFBD><EFBFBD><EFBFBD> **\n");
printf("** 3.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD><DCB7><EFBFBD><EFBFBD><EFBFBD> **\n");
printf("** 4.<2E><>Ů<EFBFBD><C5AE><EFBFBD>ܷ<EFBFBD><DCB7><EFBFBD><EFBFBD><EFBFBD> **\n");
printf("** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>в<EFBFBD><D0B2><EFBFBD>!: **");
scanf("%d",&choice);
printf("\n");
switch(choice)
{
case 1:for(i=0;i<n;i++)
{
printf("\nѧУ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%d\n",h[i].schoolnum);
printf("ѧУ<EFBFBD>ܷ<EFBFBD>:%d\n",h[i].score);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD>:%d\n",h[i].mscore);
printf("Ů<EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD>:%d\n",h[i].wscore);
printf("\n");
}
break;
case 2:for(i=0;i<n;i++)
a[i]=i;
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
if(h[a[i]].score<h[j].score)
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
for(i=0;i<n;i++)
{
printf("\n ѧУ<D1A7><D0A3><EFBFBD><EFBFBD>:%d \n",h[a[i]].schoolnum);
printf(" ѧУ<D1A7>ܷ<EFBFBD>:%d \n",h[a[i]].score);
printf(" <20><><EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD>:%d \n",h[a[i]].mscore);
printf(" Ů<><C5AE><EFBFBD>ܷ<EFBFBD>:%d \n",h[a[i]].wscore);
printf("\n");
}
break;
case 3:for(i=0;i<n;i++)
a[i]=i;
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
if(h[a[i]].mscore<h[j].mscore)
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
for(i=0;i<n;i++)
{
printf(" ѧУ<D1A7><D0A3><EFBFBD><EFBFBD>:%d \n",h[a[i]].schoolnum);
printf(" ѧУ<D1A7>ܷ<EFBFBD>:%d \n",h[a[i]].score);
printf(" <20><><EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD>:%d \n",h[a[i]].mscore);
printf(" Ů<><C5AE><EFBFBD>ܷ<EFBFBD>:%d \n",h[a[i]].wscore);
printf("\n");
}
6 years ago
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(" ѧУ<D1A7><D0A3><EFBFBD><EFBFBD>:%d \n",h[a[i]].schoolnum);
printf(" ѧУ<D1A7>ܷ<EFBFBD>:%d \n",h[a[i]].score);
printf(" <20><><EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD>:%d \n",h[a[i]].mscore);
printf(" Ů<><C5AE><EFBFBD>ܷ<EFBFBD>:%d \n",h[a[i]].wscore);
printf("\n");
}
break;
}
printf("<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1/0<><30>?:");
scanf("%d",&sign);
printf("\n");
}while(sign==1);
}
void chaxun()
{
int choice;
int i,j,k,s;
printf("\n** 1:<3A><>ѧУ<D1A7><D0A3><EFBFBD>Ų<EFBFBD>ѯ **\n");
printf("\n** 2:<3A><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>Ų<EFBFBD>ѯ **\n");
printf("\n<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>ʽ:");
scanf("%d",&choice);
switch(choice)
{
case 1:
do
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>ѧУ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&i);
if((i>n)||(i<=0))
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧУû<EFBFBD>вμӴ˴<EFBFBD><EFBFBD>˶<EFBFBD><EFBFBD><EFBFBD>!\n");
else
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&j);
if(j>m+w||j==0)
printf("******************<2A>˴<EFBFBD><CBB4>˶<EFBFBD><CBB6><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ******************\n");
else
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀȡǰ %d<><64>,<2C><>ѧУ<D1A7>ijɼ<C4B3><C9BC><EFBFBD><EFBFBD><EFBFBD>:\n", h[0].c[j-1].top);
for(k=0;k<5;k++)
if(h[i-1].c[j-1].range[k]!=0)
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%d\n",h[i-1].c[j-1].range[k]);
}
}
printf("<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1/0<><30>?:");
scanf("%d",&s);
printf("\n");
}while(s==1);
break;
case 2:
do
{
printf("Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&s);
if(s>m+w||s==0)
printf("<EFBFBD>˴<EFBFBD><EFBFBD>˶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ\n");
else
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀȡǰ %d<><64><><C8A1><EFBFBD><EFBFBD><EFBFBD>ε<EFBFBD>ѧУ\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("ѧУ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%d,<2C><><EFBFBD><EFBFBD>:%d\n",h[i].schoolnum,h[i].c[s-1].range[j]);
}
printf("<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1/0<><30>?:");
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("<EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>\n");
exit(0);
}
fputs("ѧУ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ѧУ<D1A7>ܷ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD> Ů<><C5AE><EFBFBD>ܷ<EFBFBD> ",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("<EFBFBD><EFBFBD><EFBFBD>ܹر<EFBFBD><EFBFBD>ļ<EFBFBD>\n");
exit(0);
}
}
void read()
{
FILE *fp;
int i,j,s;
if((fp=fopen("sportsdata.txt","r"))==NULL)
{
printf("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>!\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("<EFBFBD><EFBFBD><EFBFBD>ܹر<EFBFBD><EFBFBD>ļ<EFBFBD>\n");
exit(0);
}
}
6 years ago
int main()
{ FILE *fp;
6 years ago
system("color CF");
6 years ago
int choice;
int flag1=1,flag2=1;
system("cls");
do
{
printf("\n*************************************************************\n");
printf("\n** <20>˶<EFBFBD><CBB6><EFBFBD><EFBFBD>Ʒ<EFBFBD>ϵͳ **\n");
printf("\n** 1.¼<><C2BC><EFBFBD><EFBFBD>Ϣ **\n");
6 years ago
printf("\n** 2.<2E><>ʾ<EFBFBD><CABE>Ϣ **\n");
printf("\n** 3.<2E><>ѯ<EFBFBD><D1AF>Ϣ **\n");
printf("\n** 4.<2E>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD> **\n");
6 years ago
printf("\n*************************************************************\n");
printf("\n\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&choice);
if(choice==1)
flag1=0;
else
if((fp=fopen("sportsdata.txt","r"))!=NULL )
flag2=0;
else
{
system("cls");
printf("û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ!\n");
}
}while(flag1&&flag2);
switch(choice)
{
case 1:
printf("\n==========<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ========\n");
input();
write();
printf("==========<3D><>Ϣ<EFBFBD>Ѵ<EFBFBD><D1B4>뵵=========");
main();
6 years ago
case 2:
6 years ago
printf("===========<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ==========\n");
if(flag1)
read();
output();
main();
6 years ago
case 3:
6 years ago
printf("===========<3D><>ѯ<EFBFBD><D1AF>Ϣ==========\n");
if(flag1)
read();
chaxun();
main();
6 years ago
case 4:
6 years ago
printf("\nлл<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD>"); exit(0);
default:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n"); exit(0);
}}