运动员跳水时,有n个评委打分,分数为10分制,且有两位小数。得分规则为:去掉最高分和最低分,求剩下分数的平均值,就是运动员的最终得分。
Standard Input
有多组测试数据。第一行是整数T (T <= 100),表示测试数据的组数,随后有T组测试数据。每一组测试数据占一行,分别为整数n和n个评委的打分,相邻数之间有一个空格。其中,2<n≤100。
Standard Output
对应每组输入,输出该运动员的得分,保留2位小数。
Samples
Input | Output |
---|---|
3 9 6.21 9.19 6.34 9.22 6.85 8.50 6.85 6.95 6.03 8 6.75 6.23 9.86 9.37 6.90 7.88 9.13 6.15 9 9.11 7.68 8.93 7.53 8.92 9.52 7.78 8.70 6.69 | 7.27 7.71 8.38 |
Problem ID | 1888 |
Problem Title | 跳水打分问题 |
Time Limit | 1000 ms |
Memory Limit | 64 MiB |
Output Limit | 64 MiB |
Source | wxiaoping - 2018.4.16 |
#include <stdio.h>
#include <stdlib.h>
int main()
{
int T,c;
scanf("%d", &T);
float a[100],b[100],d[100],max,min,sum;
for (c = 0; c < T; c++) {
sum =0.0;
scanf("%f", &b[c]);
for (int e= 0; e< b[c]; e++) {
scanf("%f", &a[e]);
}
max=a[0];min=a[0];
for(int i=0;i<b[c];i++)
{
if(max<a[i])
max=a[i];
if(min>a[i])
min=a[i];
sum=sum+a[i];
}
d[c] = (sum-max-min) / (b[c] - 2);
}
for (int p = 0; p < T; p++){
printf("%.2f\n", d[p]);
}
return 0;
}