5 solutions
-
0
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <iomanip> using namespace std; int main() { int n; cin >> n; vector<double> samples(n); for (int i = 0; i < n; ++i) { cin >> samples[i]; } sort(samples.begin(), samples.end()); // 对样本进行排序 double sum = 0.0; for (int i = 1; i < n - 1; ++i) { sum += samples[i]; } double average = sum / (n - 2); // 平均白细胞数量 double maxDiff = 0.0; for (int i = 1; i < n - 1; ++i) { maxDiff = max(maxDiff, abs(samples[i] - average)); } cout << fixed << setprecision(2) << average << " " << maxDiff << endl; return 0; }
这个是对的,可以试一试,不对的话给差评,如果是对的,麻烦给个好评,谢谢!
Information
- ID
- 897
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 3
- Tags
- (None)
- # Submissions
- 229
- Accepted
- 40
- Uploaded By