为什么我电脑上安装了省级二级c语言模拟考试系统后,编程题做不起来,点击打开没反应,已经安装了VC6
- 提问者网友:眉目添风霜
- 2021-02-26 05:45
- 五星知识达人网友:酒安江南
- 2021-02-26 06:53
- 1楼网友:你哪知我潦倒为你
- 2021-02-26 08:30
#include <stdio.h> typedef struct { char name[21]; int score[5]; double avg; }per; void sort(per x[],int n) { int i,j; per t; for(i=0;i<n;i++) for(j=i+1;j<n;j++) if(x[i].avg<x[j].avg) t=x[i],x[i]=x[j],x[j]=t; } void average(per x[],int n) { int i,min,j,m; for(i=0;i<n;i++) { min=x[i].score[0]; for(j=1;j<5;j++) if(min<x[i].score[j])min=x[i].score[j]; x[i].avg=m=0; for(j=0;j<5;j++) if(x[i].score[j]!=min)x[i].avg+=x[i].score[j],m++; x[i].avg/=m; } }
void main() { per x[10]={ {"a1",96,98,91,89,88}, {"a2",90,96,95,96,91}, {"a3",96,98,91,89,84}, {"a4",90,96,95,96,92}, {"a5",96,98,91,89,80}, {"a6",90,96,95,96,96}, {"a7",96,98,91,89,86}, {"a8",90,96,95,96,93}, {"a9",96,98,91,89,83}, {"a10",90,96,95,96,99} }; int i; average(x,10); sort(x,10); printf("一等奖:\n%s %.2lf\n",x[0].name,x[0].avg); printf("二等奖:\n"); for(i=1;i<3;i++) printf("%s %.2lf\n",x[i].name,x[i].avg); printf("三等奖:\n"); for(i=3;i<10;i++) printf("%s %.2lf\n",x[i].name,x[i].avg);
}