From 7cc8be5aac99f0cd3a0a23d042bf5fbd081a96be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E9=9D=92=E8=89=B3?= <18373302181@139.com> Date: Fri, 11 Jan 2019 00:46:32 +0800 Subject: [PATCH] first commit --- 第十一题啊啊啊.cpp | 146 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 第十一题啊啊啊.cpp diff --git a/第十一题啊啊啊.cpp b/第十一题啊啊啊.cpp new file mode 100644 index 0000000..2d9cfc8 --- /dev/null +++ b/第十一题啊啊啊.cpp @@ -0,0 +1,146 @@ +#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: //ѡ + 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); + for(i=0;i