题解 | #记负均正II#
记负均正II
https://www.nowcoder.com/practice/64f6f222499c4c94b338e588592b6a62
#include <stdio.h> int main() { int a; int cnt = 0; int pstv_cnt = 0; int total = 0; while (scanf("%d", &a) != EOF) { // 注意 while 处理多个 case if (a < 0) cnt++; else { pstv_cnt++; total += a; } } printf("%d\n%0.1f\n", cnt, (pstv_cnt != 0) ? (float)total / pstv_cnt : 0.0); return 0; }