题解 | #记负均正II#

记负均正II

https://www.nowcoder.com/practice/64f6f222499c4c94b338e588592b6a62

l=[]
count_nagetive = 0
count_not_nagetive = 0
sum = 0
while True:
    try:
        l.append(int(input()))
    except:
        break
for i in l:
    if i < 0:
        count_nagetive += 1
    else:
        count_not_nagetive += 1
        sum += i
print(f"{count_nagetive}")
if count_not_nagetive == 0:
    print("0.0")
if count_not_nagetive > 0:
    print("%.1f"%(sum/count_not_nagetive))

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务