题解 | #进制转换#
进制转换
http://www.nowcoder.com/practice/8f3df50d2b9043208c5eed283d1d4da6
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); String num=sc.nextLine().substring(2).toUpperCase(); int res=0; int temp; while(num.length()>0){ if(num.charAt(0)>='A'&&num.charAt(0)<='F'){ temp=num.charAt(0)-'A'+10; }else{ temp=num.charAt(0)-'0'; } res=res*16+temp; num=num.substring(1); } System.out.println(res); } }