题解 | #进制转换#
进制转换
http://www.nowcoder.com/practice/8f3df50d2b9043208c5eed283d1d4da6
while(line = readline()){ change(line) } function change(line) { let n = line.substring(2) let number = 0 for(let i=0;i<n.length;i++) { let codeAt = n.charCodeAt(i) let num = 0 switch(codeAt){ case 48: num=0 break case 49: num=1 break case 50: num=2 break case 51: num=3 break case 52: num=4 break case 53: num=5 break case 54: num=6 break case 55: num=7 break case 56: num=8 break case 57: num=9 break case 65: num=10 break case 66: num=11 break case 67: num=12 break case 68: num=13 break case 69: num=14 break case 70: num=15 break } number = number*16+num } console.log(number) }