思路
遍历。
代码
while True: try: n = int(input()) s = list(map(int, input().strip().split())) c = 0 v = 0 sum = 0 for i in s: if i<0: c += 1 elif i>0: v += 1 sum += i print(str(c)+" "+f"{sum/v:.1f}") except: break
遍历。
while True: try: n = int(input()) s = list(map(int, input().strip().split())) c = 0 v = 0 sum = 0 for i in s: if i<0: c += 1 elif i>0: v += 1 sum += i print(str(c)+" "+f"{sum/v:.1f}") except: break