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.

148 lines
3.3 KiB

6 years ago
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include<string.h>
#define M 10 //<2F><EFBFBD><EAB6A8><EFBFBD><EFBFBD>ί<EFBFBD><CEAF><EFBFBD><EFBFBD>
struct player //<2F><EFBFBD><EFBFBD><E5B6A8>ѡ<EFBFBD><D1A1>
{
int num;
char name[8];
int score[M];
};
void Intplayer(struct player a[],int n) //<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD><DDBA><EFBFBD>
{
int i;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d",&n);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ѧ<EFBFBD>ź<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
for(i=0;i<n;i++)
scanf("%d %s",&a[i].num,&a[i].name);
}
void sort(struct player a[],float b[],int n) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
int i,k,j,t;
float temp;
char str[8];
for(i=0;i<n;i++)
{
k=i;
for(j=i+1;j<n;j++)
if(b[k]>b[j])
k=j;
if(k!=i)
{
temp=b[i];
b[i]=b[k];
b[k]=temp;
strcpy(str,a[i].name);
strcpy(a[i].name,a[k].name);
strcpy(a[k].name,str);
t=a[i].num;
a[i].num=a[k].num;
a[k].num=t;
}
}
}
void main()
{
system("color F4"); //<2F>׵׺<D7B5><D7BA><EFBFBD>
int flag=1,n,i,m,j,r;
FILE *fp;
fp = fopen("data.txt","w+"); //<2F>ļ<EFBFBD>д<EFBFBD><D0B4>λ<EFBFBD><CEBB>
struct player a[20];
float aver[99]={0};
int sum[99]={0};
int Max[99];
int Min[99];
int add=2;
printf(" <20><><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>˵<EFBFBD>\n");
printf("************************************************************\n");
printf(" **********1.<2E><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>***********\n");
printf(" **********2.<2E><>ί<EFBFBD><CEAF><EFBFBD><EFBFBD>***************\n");
printf(" **********3.<2E>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>***************\n");
printf(" **********4.<2E><><EFBFBD>ݲ<EFBFBD>ѯ***************\n");
printf(" **********5.׷<><D7B7>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>***********\n");
printf(" **********6.д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>***********\n");
printf(" **********7.<2E>˳<EFBFBD>ϵͳ***************\n");
printf("*************************************************************\n\n\n\n");
while(flag)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еIJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d",&r);
switch(r)
{
case 1:
Intplayer(a,n); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD><DDBA><EFBFBD>
break;
case 2:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d",&n);
for(i=0;i<n;i++) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>
{
printf("%d<><64>ѡ<EFBFBD>ֵ÷<D6B5><C3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n",i+1);
for(j=0;j<M;j++) //<2F><>ί<EFBFBD><CEAF><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>
{
printf("<EFBFBD><EFBFBD>%dλ<64><CEBB>ί<EFBFBD><CEAF><EFBFBD>֣<EFBFBD>",j+1);
scanf("%d",&a[i].score[j]);
}
}
break;
case 3:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d",&n);
for(i=0;i<n;i++)
{
Max[i]=a[i].score[0];
Min[i]=a[i].score[0];
for(j=0;j<M;j++) //<2F>ж<EFBFBD>ijѡ<C4B3>ֵ÷<D6B5><C3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Сֵ
{
sum[i]+=a[i].score[j];
if(Max[i]<a[i].score[j])
Max[i]=a[i].score[j];
if(Min[i]>a[i].score[j])
Min[i]=a[i].score[j];
}
aver[i]=(float)(sum[i]-Max[i]-Min[i])/(M-2);
}
sort(a,aver,n); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(i=0;i<n;i++)
printf("%s %5.2f\n",a[i].name,aver[i]);
break;
case 4:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯѡ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&m);
for(i=0;i<n;i++)
if(a[i].num==m)
{
printf("%d<><64>ѡ<EFBFBD><D1A1>%s<>ܷ<EFBFBD>:%d,<2C><><EFBFBD>߷<EFBFBD>%d,<2C><><EFBFBD>ͷ<EFBFBD>%d,ƽ<><C6BD><EFBFBD><EFBFBD>%5.2f",a[i].num,a[i].name,sum[i],Max[i],Min[i],aver[i]);
printf("\n");
}
break;
case 5:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ׷<EFBFBD>ӵ<EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>\n");
add += 1;
scanf("%d %s",&a[add].num,&a[add].name);
break;
case 6:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>У<EFBFBD>\n");
for (i = 0 ; i < add+1 ; i++)
{
fprintf(fp,"%d ",a[i].num);
fprintf(fp,"%s ",a[i].name);
fprintf(fp,"%d\n",a[i].score);
}
break;
case 7:exit(0);
break;
default:flag=0;
}
}
}