Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
54352 | zhangsicun | 白细胞计数 | C++ | 通过 | 0 MS | 260 KB | 938 | 2024-10-27 11:57:49 |
#include<bits/stdc++.h> using namespace std; int main(){ int n, k, l, t = 0; cin >> n; double a[300], sum = 0; for(int i = 0; i < n; i++){ cin >> a[i]; } double largest = -100, smallest = 10000, larg = -100; for(int i = 0; i < n; i++){ if(a[i] > largest){ largest = a[i]; k = i; } if(a[i] < smallest){ smallest = a[i]; l = i; } } a[k] = 0; a[l] = 0; for(int i = 0; i < n; i++){ if(a[i] != 0){ sum += a[i]; } } double ave = sum/(n - 2); double b[300]; for(int i = 0; i < n; i++){ if(a[i] != 0){ b[t] = abs(a[i]-ave); t++; } } for(int i = 0; i < n - 2; i++){ if(b[i] > larg){ larg = b[i]; } } cout << fixed << setprecision(2) << ave <<" " << larg <<endl; return 0; }