青年歌手大奖赛_评委会打分
题目分析:
判断出最大值和最小值,然后删去,最后将留下的数进行平均
代码:
#include <iostream> using namespace std; int main() { int n; while (cin>>n) { int score, sum = 0, max = 0, min = 101, i; for (i = 1; i <= n; i++) { cin >> score; sum += score; max = (score > max) ? score : max; min = (score < min) ? score : min; } printf("%.2f ", (float)(sum - max - min) / (n - 2)); } system("pause"); return 0; }