题解 | #明明的随机数#

明明的随机数

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

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
    let array = [];
    let count = 0;
    while(line = await readline()){
        count = count + 1;
        let ele = Number(line)
        if(count > 1 && array.indexOf(ele) === -1){
            array.push(ele)
        }
    }
    array = array.sort((a, b) => a-b)
    for(let item of array) {
        console.log(item)
    }
}()

#华为机试HJ3#
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务