6、键盘输入7个评委对选手的打分,去掉最高分,去掉最低分,输出平均分,要求左对齐,保留到小数点后两位。
#include <stdio.h>
int main (){
int i,j,temp,sum=0;
int gread[7];
float b;
printf("please input your score:\n");
for(i=0;i<7;i++)
scanf("%d",&gread[i]);
for(i=0;i<6;i++){
for(j=i+1;j<7;j++){
if(gread[i]<gread[j]){
temp=gread[i];
gread[i]=gread[j];
gread[j]=temp;
}
}
}
for(i=1;i<6;i++){
sum += gread[i];
b=sum/5.0;
}
printf("zui hou ping jun fen A=%5.2f\n",b);
}