package com.huawei.practice002; import java.util.Scanner; /** * @author Allen * @version 创建时间: * 类说明:十六进制字符串转十进制 */ public class Jinzhizhuanhuan10to2 { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); do{ String str=scanner.nextLine(); char[] strArr=str.toCharArray(); int i,sum=0,j=0; for(i=2; i<strArr.length; i++){ if(strArr[i]<='9'){ j=strArr[i]-'0'; }else if(strArr[i]>='A'){ j=strArr[i]-'A'+10; } sum=sum*16+j; } System.out.println(sum); }while(!scanner.hasNext("exit")); } }