杭电ACM2014:青年歌手打分

    xiaoxiao2021-04-19  188

    #include <iostream> using namespace std; int main(){ double sum = 0, avr; int n,max=0,min=100; int a[100]; while (cin >> n){ for (int i = 0; i < n; i++){ cin >> a[i]; if (a[i] > max) max = a[i]; if (a[i] < min) min = a[i]; sum = sum + a[i]; } sum = sum - max - min; avr = sum / (n - 2); cout.precision(2); cout << fixed << avr << endl; sum = 0; max = 0; min = 100; } }

    sum,max,min最后要重新赋值。

    转载请注明原文地址: https://ju.6miu.com/read-676214.html

    最新回复(0)