commit 3de1f897a877507127e8915599540aa494f4b8da Author: 林青艳 <18373302181@139.com> Date: Fri Jan 11 16:23:01 2019 +0800 first ccommit diff --git a/11题.c b/11题.c new file mode 100644 index 0000000..5f42ff0 --- /dev/null +++ b/11题.c @@ -0,0 +1,162 @@ +#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[10]; + 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,r=1; //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("\n"); + printf("밴1-7˳Խв"); + abc: + scanf("%d",&n); + if(r==n) + { r++; + 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