题解 | #记负均正II#
记负均正II
https://www.nowcoder.com/practice/64f6f222499c4c94b338e588592b6a62
#include <stdio.h> #include <string.h> int main() { double a[2010]; double sum = 0; int count = 0; int j = 0, i = 0; while (scanf("%lf ", &a[i]) != EOF) { if (a[i] >= 0) { sum += a[i]; j++; } if (a[i] < 0) count++; } if (sum == 0) printf("%d\n%.1lf\n", count, sum); else printf("%d\n%.1lf\n", count, sum / j); return 0; }