华为机试-记负均正(HJ105)-纯C
记负均正II
http://www.nowcoder.com/questionTerminal/64f6f222499c4c94b338e588592b6a62
纯C
这题不应该归为较难的把,属于简单的吧!
#include <stdio.h> #include <string.h> int main() { int num, cnt1=0, cnt2=0, sum=0; while(scanf("%d",&num) != EOF) { if(num < 0) { cnt1++; } else { sum += num; cnt2++; } } float result =(cnt2>0)?((float) sum / cnt2):0; printf("%d\n%0.1f\n",cnt1,result); return 0; }