4024 - 歌唱比赛
在歌唱比赛中,有10个评委为参赛的选手打分,分数为1~100分。选手最后得分为:去掉一个最高分和一个最低分后其余8个分数的平均值,保留2位小数。请编写一个程序实现。
题目输入
一行十个数,表示选手得分,选手得分可以用小数表示,比如80.5分。
题目输出
一行,选手平均分。
输入/输出样例
题目输入
10 20 30 40 50 60 70 80 90 100
题目输出
55.00
C++解答
#include<iostream> #include<cstdio> using namespace std; int main() { float score,max,min,sum,ave; sum=0; max=0; min=101; for (int i=1; i<=10; i++) { cin>>score; sum+=score; if (score>max) max=score; if (score<min) min=score; } sum-=max+min; ave=sum/8; printf("%.2f\n",ave); return 0; }