题解 | #记负均正II#
记负均正II
http://www.nowcoder.com/practice/64f6f222499c4c94b338e588592b6a62
就是简单的数据处理,不明白为啥这个题的难度是较难
#include <stdio.h> int main(void) { float num; int count1 = 0; int count2 = 0; int array[1000]; int i = 0; float re = 0; while(scanf("%f", &num) != EOF) { if(num < 0) { count1++; } else if(num >= 0) { re += num; count2++; } } printf("%d\n", count1); if(count2 == 0) printf("%.1f",(float)count2); else if(count2 > 0) printf("%.1f\n", (float)(re / count2)); return 0; }