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 #include <climits>

 3 int main()

 4 {

 5    int n,score,min,max;

 6    double ans;

 7    while(~scanf("%d",&n))

 8       {

 9          min=INT_MAX;max=INT_MIN;

10          ans=0;

11          for(int i=0;i<n;i++)

12             {

13                scanf("%d",&score);

14                min=score<min? score:min;

15                max=score>max? score:max;

16                ans=ans+score;  

17             }

18          printf("%.2lf\n",(ans-max-min)/(n-2));

19       }

20    return 0;

21 }

 

你可能感兴趣的:(HDU)