题解 | #进制转换#
进制转换
https://www.nowcoder.com/practice/8f3df50d2b9043208c5eed283d1d4da6
测试案例居然没有小写字母,(c.charCodeAt()-"A".charCodeAt()+10)用得真爽
const rl = require("readline").createInterface({input:process.stdin});
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void async function(){
const str = await readline();
const len = str.length;
let res = 0,cnt = 1;
for(let i = len-1; i >=2; i--){
const c = str.charAt(i);
res += c>"9"?(c.charCodeAt()-"A".charCodeAt()+10)*cnt:(c-0)*cnt;
cnt *= 16;
}
console.log(res);
}()
