题解 | 取近似值

取近似值

https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a

const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;

void async function () {
    // Write your code here
  while(line = await readline()) {
        // 读取输入并转换为数字
        let num = parseFloat(line);
        
        // 使用Math.round进行四舍五入
        let rounded = Math.round(num);
        
        // 输出结果
        console.log(rounded);
    }
}()

全部评论

相关推荐

饿魔:没人说?我来牛美孩
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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