题解 | 进制转换

进制转换

https://www.nowcoder.com/practice/8f3df50d2b9043208c5eed283d1d4da6

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
const enumArr  = {
"0":0,
"1":1,
"2":2,
"3":3,
"4":4,
"5":5,
"6":6,
"7":7,
"8":8,
"9":9,
"A":10,
"B":11,
"C":12,
"D":13,
"E":14,
"F":15
}
rl.on('line', function (line) {
    let num=0;
    line = line.slice(2);
    line.split('').map((item,index)=>{
        num =num + enumArr[item]*Math.pow(16,line.length-1-index)
    })
    console.log(num)
});

#宣讲会你有哪些意向不到的收获##为了求职,我做过的疯狂伪装##我的秋招日记##从顶到拉给所有面过的公司评分##bilibili求职进展汇总#
全部评论

相关推荐

12-15 12:50
河北工程大学
sta666:我也是这个国际商业化的,三天,一天一面,就通过了,不过我是后端实习生,好好面感觉能过。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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