题解 | #记负均正#
记负均正
https://www.nowcoder.com/practice/6abde6ffcc354ea1a8333836bd6876b8
n = int(input())
num = [int(x) for x in input().split()]
count_p, count_n = 0, 0# 分别用于统计正负数的个数
sum = 0
for i in num:
if i < 0:
count_n += 1
elif i > 0:
count_p += 1
sum += i
if count_p == 0:
ave = 0.0
else:
ave =float(sum/count_p)
print(count_n, '%.1f' %ave)
查看8道真题和解析