题解 | 取近似值

import math
//注意不能用round,因为这个是银行家舍入法,即“四舍六入五取偶”
def flour0ut_fivein(n):
	//向上取整
    n_min = math.floor(n)
	//向下取整
    n_max = math.ceil(n)
	//判断
    if n-n_min >=0.5:
        n = n_max
    else:
        n = n_min
    return n
	//主要要将输入的值转换为浮点型
n = float(input().strip())
print(flour0ut_fivein(n))

全部评论

相关推荐

点赞 评论 收藏
分享
但听说转正率很低,我现在有在实习了,好纠结要不要去
熬夜脱发码农:转正率低归低,但是实习的经历你可以拿着,又不是说秋招不准备了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务