题解 | #记负均正#
记负均正
http://www.nowcoder.com/practice/6abde6ffcc354ea1a8333836bd6876b8
#include<stdio.h> #include<math.h> int main() { int num; int a[1000]; while(scanf("%d",&num)!=EOF) { int count = 0; int countint =0; float sum = 0; for(int i =0;i<num;i++) { scanf("%d",&a[i]); if(a[i]<0) { count++; } if(a[i]>0) { countint++; sum+=a[i]; } } printf("%d %0.1f\n",count,sum/countint); } }