
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
int n;
while (cin >> n) {
int num = n;
float score = 0.0;
int maxVal = INT_MIN;
int minVal = INT_MAX;
int temp;
while (n--) {
cin >> temp;
maxVal = max(maxVal, temp);
minVal = min(minVal, temp);
score += temp;
}
num -= 2;
score = score - maxVal - minVal;
printf("%.2f\n", score / num);
}
return 0;
}

本文展示了一个C++程序,通过输入一组整数,计算并输出不包括最大值和最小值的平均数。使用了`<algorithm>`库中的`max`和`min`函数以及基本的循环结构。
418

被折叠的 条评论
为什么被折叠?



