一、题目
二、示例
三、代码
while True:
try:
negative = 0
positiv = []
n = int(input())
temp = input().split()
for item in temp:
if int(item) > 0:
positiv.append(int(item))
if int(item) < 0:
negative += 1
print(negative, '%.1f' % (sum(positiv) / len(positiv)))
except:
break
四、算法说明
将输入的 n 个整数分割为列表,进行遍历,将正数存入列表 positiv
,统计负数的个数,打印输出负数的个数,以及所有正数的平均值,并保留一位小数。
胡萝卜
2022年1月26日12:07:16
我不知道将去向何方,但我已在路上! |
---|
时光匆匆,虽未曾谋面,却相遇于斯,实在是莫大的缘分,感谢您的到访 ! |