题解 | #进制转换#
进制转换
https://www.nowcoder.com/practice/8f3df50d2b9043208c5eed283d1d4da6
import java.util.*; public class Main{ public static void main(String[] args){ Scanner in = new Scanner(System.in); while(in.hasNext()){ String str = in.nextLine().substring(2).toLowerCase(); int base = 16; int res=0; for(char ss:str.toCharArray()){ int t=0; if(ss>='0' && ss<='9'){ t=ss-'0'; } else if(ss>='a' && ss<='f'){ t=ss-'a'+10; } res=res*base+t; } System.out.println(res); } } }