题解 | #记负均正#
记负均正
https://www.nowcoder.com/practice/6abde6ffcc354ea1a8333836bd6876b8
#include <stdio.h> int main() { int n = 0; scanf("%d",&n); int arr[n]; int count1 = 0; float sum = 0.0; int count2 = 0; for(int i = 0;i < n;i++) { scanf("%d",&arr[i]); if(arr[i] < 0) { count1++; } else if(arr[i] > 0) { sum += arr[i]; } else { count2++; } } if(count2 != n) { printf("%d %.1f\n",count1,sum / (n - count1 - count2)); } else { printf("0 0.0"); } return 0; }