题解 | #HJ7 取近似值#
取近似值
https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
# 方法1 num = float(input()) int_part = int(num) float_part = num - int_part if float_part >= 0.5: print(int_part + 1) else: print(int_part) # 方法2 # n = float(input()) # y = lambda x: int(x+0.5) # print(n)
【牛客站内】华为机试题解 文章被收录于专栏
【牛客站内】 分享个人刷题的思路和解法