华为机试HJ105记负均正II 题目: 想法: 分别记录输入中的正数和负数,根据规则计算平均值即可 count = 0 sum = 0 sum_count = 0 while True: try: number = float(input()) if number < 0: count += 1 elif number >= 0: sum += number sum_count += 1 except: break if sum == 0: print(count) print(0.0) else: print(count) print("%.1f"%(sum/sum_count))