HDU_2014 青年歌手大奖赛_评委会打分

Problem Description
青年歌手大奖赛中,评委会给参赛选手打分。选手得分规则为去掉一个最高分和一个最低分,然后计算平均得分,请编程输出某选手的得分。
 
Input
输入数据有多组,每组占一行,每行的第一个数是n(2<n<=100),表示评委的人数,然后是n个评委的打分。
 
Output
对于每组输入数据,输出选手的得分,结果保留2位小数,每组输出占一行。
 
Sample Input
3 99 98 97 4 100 99 98 97
 
Sample Output
98.00 98.50
代码如下:
 1 #include <cstdio>
 2 int main(){
 3     int n,score[105],temp;
 4     double ave=0;
 5     while(scanf("%d",&n)!= EOF){
 6     for(int i=0;i<n;i++){
 7         scanf("%d",&score[i]);
 8     }
 9     for(int i=0;i<n-1;i++){
10         for(int j=0;j<n-1-i;j++){
11             if(score[j]>score[j+1]){
12                 temp=score[j];
13                 score[j]=score[j+1];
14                 score[j+1]=temp;
15             }
16         }
17     }
18     for(int k=1;k<n-1;k++){
19         ave+=score[k];
20     }
21     ave=ave/(n-2);
22     printf("%.2lf
",ave);
23     ave=0;
24 }
25     return 0;
26 } 

思路解析

    今天偷懒了。。好累的说。更一道水题吧。
原文地址:https://www.cnblogs.com/xzt6/p/5763199.html