JS node题解 | #明明的随机数#

明明的随机数

https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0

const rl = require("readline").createInterface({
    input: process.stdin,
    output: process.stfout,
});
const inputArr = [];
const asc = (a, b) => {
    return a - b;
};
rl.on("line", function (line) {
    inputArr.push(parseInt(line));
    let nLine = +inputArr[0];
    if (inputArr.length == nLine + 1) {
        let arr = inputArr.slice(1);
        // console.log('arr', arr)
        let newarr = [...new Set(arr)];
        newarr = newarr.sort(asc);
        for (item of newarr) {
            console.log(item);
        }
    }
});

全部评论

相关推荐

10-14 21:00
门头沟学院 Java
吃花椒的狸猫:这个人说的倒是实话,特别是小公司,一个实习生哪里来的那么多要求
点赞 评论 收藏
分享
09-28 22:01
已编辑
广西科技大学 IT技术支持
合适才能收到offe...:找桌面运维?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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