题解 | #记负均正II#
记负均正II
https://www.nowcoder.com/practice/64f6f222499c4c94b338e588592b6a62
#include <iostream> using namespace std; int main() { int val,cnt=0; double sum=0,n=0; while (cin >> val){ if (val < 0) { cnt++; } else{ sum += val; n++; } } cout << cnt <<endl; double ans; if (n!=0){ ans = sum / n; } else { ans = 0; } printf("%0.1lf\n", ans); return 0; }