commit 9c54dc2f103887f96004dbeecbac2796967c299c Author: 林青艳 <18373302181@139.com> Date: Fri Jan 11 11:20:13 2019 +0800 first commit diff --git a/11题.c b/11题.c new file mode 100644 index 0000000..1a033af --- /dev/null +++ b/11题.c @@ -0,0 +1,147 @@ +#include +#include //ڴ亯 eg:exit() +#include //ַ +#define N 3 +#define M 10 +int add = N - 1; +int sum[N] = { 0 }, Max[N], Min[N]; +float aver[N] = { 0 }; +struct player //ṹ +{ + int num; // + char name[8]; // + int score[M]; //÷ +}; + +void Inistplayer(struct player a[], int n) +{ + int i; + for (i = 0; i < n; i++) + scanf("%d %s", &a[i].num, a[i].name); //¼ѡ +} +void Inputscore(int score[], int n) //ί +{ + int i; + for (i = 0; i < n; i++) + scanf("%d",&score[i]); +} +void sort(struct player a[], float b[], int n) //sort== +{ + int i, k, j,t; + float temp; //temp:ʱļ + //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ǸַĵĿ⺯ + 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:жϱ־ + FILE *fp; + struct player a[20]; + printf("||=========================================================================||\n"); + printf("||============================˵=======================================||\n"); + printf("||************************ֱϵͳ*********************************||\n"); + printf("||=========================================================================||\n"); + printf("|| 1.ѡ ||\n"); + printf("|| 2.ί ||\n"); + printf("|| 3.ɼ ||\n"); + printf("|| 4.ݲѯ ||\n"); + printf("|| 5.׷ѧ ||\n"); + printf("|| 6.дļ ||\n"); + printf("|| 7.˳ϵͳ ||\n"); + printf("||=========================================================================||\n"); + printf("||*************************************************************************||\n"); + printf("||*************************************************************************||\n"); + while(flag) + { + printf("ԽеIJ"); + scanf("%d",&n); + switch(n) + { + case 1: + printf("λѡֵ ( eg:1 XXX)\n") ; //ѡ + Inistplayer(a,N); + break; + case 2: //ί + for(i=0;ia[i].score[j]) + Min[i]=a[i].score[j]; + } + aver[i]=(float)(sum[i]-Max[i]-Min[i])/(M-2); //ƽֵ + + } + sort(a,aver,N); //a[0]NС󣩣ƽֵ + for(i=0;i