题解 | #记负均正#
记负均正
https://www.nowcoder.com/practice/6abde6ffcc354ea1a8333836bd6876b8
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { double negCount = 0, posCount = 0; double sum = 0; for (int i = 0;i < n;i++) { double m; cin >> m; if (m < 0) { negCount++; } else if (m > 0) { posCount++; sum += m; } } if (posCount == 0) { cout << negCount << " " << fixed << setprecision(1) << 0.0 << endl; continue; } double flt = sum / posCount; cout << negCount << " " << fixed << setprecision(1) << flt << endl; } }