题解 | #取近似值#
取近似值
https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
import sys num = input() #法一: #用round()函数,但该函数遇5时,偶数舍奇数进,所以加上较长位数的0.000001 #print(round(float(num) + 0.0000001)) #法二: #切片取小数部分与0.5比较 i = num.index('.') n = int(num[:i]) f = float("0" + num[i:]) if f < 0.5: print(n) else: print(n+1)