题解 | #记负均正#
记负均正
https://www.nowcoder.com/practice/6abde6ffcc354ea1a8333836bd6876b8
#include <iostream> using namespace std; int main() { int n,num; int cnt = 0; double m = 0, sum = 0; cin >> n; while (n--){ cin >> num; if (num < 0){ cnt++; } else if (num > 0){ sum += num; m++; } else{ } } cout << cnt << " "; if (m !=0) printf("%0.1f", sum / m); else printf("%0.1f", sum); }