题解 | #记负均正#
记负均正
https://www.nowcoder.com/practice/6abde6ffcc354ea1a8333836bd6876b8
#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> //HJ97 记负均正 int main() { int n,m; int zheng = 0; int fu = 0; int zongshu = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &m); if (m > 0) { zongshu += m; zheng++; } if (m < 0) { fu++; } else { ; } } if (zheng == 0) { printf("%d %.1f", fu, (double)zheng); } else { printf("%d %.1f", fu,(double)zongshu/zheng); } return 0; }