牛客代码提交:数组越界非法访问,野指针乱访问,空指针乱访问
importjava.util.Scanner;
publicclassMain {
publicstaticintconversion(String str){
intn=0;
for(inti=1,k=0;i<str.length()-1;i++,k++){
charch=str.charAt(str.length()-i);
intj=0;
if(ch>='0'&&ch<='9'){
j=ch-48;
}elseif(ch>='A'&&ch<='F'){
j=ch-55;
}
n=n+(int)Math.pow(16,k)*j;
}
returnn;
}
publicstaticvoidmain(String[] args){
Scanner
scanner=newScanner(System.in);
while(scanner.hasNextLine()){
String
str=scanner.next();
intn=conversion(str);
System.out.println(n);
}
}
}