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.
pbfianv8o/第十一题啊啊啊.cpp

147 lines
4.3 KiB

6 years ago
#include<stdio.h>
#include<stdlib.h> //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEBAAF><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><E4BAAF> eg:exit()
#include<string.h> //<2F>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define N 3
#define M 10
int add = N - 1;
int sum[N] = { 0 }, Max[N], Min[N];
float aver[N] = { 0 };
struct player //<2F><EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
int num; //<2F><><EFBFBD><EFBFBD>
char name[8]; //<2F><><EFBFBD><EFBFBD>
int score[M]; //<2F>÷<EFBFBD>
};
void Inistplayer(struct player a[], int n)
{
int i;
for (i = 0; i < n; i++)
scanf("%d %s", &a[i].num, a[i].name); //¼<><C2BC>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
void Inputscore(int score[], int n) //<2F><>ί<EFBFBD><CEAF><EFBFBD><EFBFBD>
{
int i;
for (i = 0; i < n; i++)
scanf("%d",&score[i]);
}
void sort(struct player a[], float b[], int n) //sort==<3D><><EFBFBD><EFBFBD>
{
int i, k, j,t;
float temp; //temp:<3A><>ʱ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
//struct player temp1;
char str[8];
for (i = 0; i < n-1; 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<70>Ǹ<EFBFBD><C7B8><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>ĵĿ⺯<C4BF><E2BAAF>
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;
}
}
}
int main()
{
int flag = 1, n, i, m, j; //flag:<3A>жϱ<D0B6>־
FILE *fp;
struct player a[20];
printf("||===============================================================================||\n");
printf("||===============================<3D><><EFBFBD>˵<EFBFBD>==========================================||\n");
printf("||***************************<2A><><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><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");
printf("||*******************************************************************************||\n");
printf("||*******************************************************************************||\n");
while(flag)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><EFBFBD>еIJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d",&n);
switch(n)
{
case 1: //<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Inistplayer(a,N);
break;
case 2: //<2F><>ί<EFBFBD><CEAF><EFBFBD><EFBFBD>
for(i=0;i<N;i++)
{
printf("%dλѡ<CEBB>ֵijɼ<C4B3><C9BC><EFBFBD>",i+1);
Inputscore(a[i].score,M); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ί<EFBFBD><CEAF><EFBFBD><EFBFBD>
for(j=0;j<M;j++)
printf("%d\t",a[i].score[j]); //<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD>ֵĸ<D6B5><C4B8>Ե÷<D4B5>
printf("\n");
}
break;
case 3: //<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
for(i=0;i<N;i++)
{
Max[i]=a[i].score[0];
Min[i]=a[i].score[0];
for(j=0;j<M;j++)
{
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); //<2F><><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD>ֵ
}
sort(a,aver,N);
for(i=0;i<N;i++)
printf("%s\t%5.2f\n",a[i].name,aver[i]);
break;
case 4: //<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>ѡ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>");
scanf("%d",&m); //mΪ<6D><CEAA>ѡ<EFBFBD>ֱ<EFBFBD><D6B1>ŵı<C5B5><C4B1><EFBFBD>
for(i=0;i<N;i++)
if(a[i].num==m)
{
printf("%d <20><>ѡ<EFBFBD><D1A1>%s <20>ܷ<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: //׷<><D7B7>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ׷<EFBFBD>ӵ<EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
add=add+1;
scanf("%d %s",&a[add].num,a[add].name);
break;
case 6: //д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>\n");
fp=fopen("date.txt","w");
for(int i=0;i<add+2;i++)
{
fprintf(fp,"%d %s\n",a[i].num,a[i].name);
}
printf("д<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n");
fclose(fp);
break;
case 7: //<2F>˳<EFBFBD>ϵͳ
exit(0);
break;
default:flag=0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>
}
}
return 0;
}