题解 | #记负均正#

记负均正

https://www.nowcoder.com/practice/6abde6ffcc354ea1a8333836bd6876b8

n = int(input())

li = list(map(int, input().split()))

counter = 0
sum = 0
counter2 = 0

for i in li:
    if i < 0:
        counter += 1
    elif i > 0:
        sum += i
        counter2 +=1
if counter2 != 0:    # 0不能做分母
    res = sum / counter2
else:
    res = 0


print(counter,f'{res:.1f}')

全部评论

相关推荐

Natrium_:这时间我以为飞机票
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务