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