import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String str=sc.nextLine();
String h=Integer.toHexString(Integer.valueOf(str,16)).toUpperCase(); //转换为16进制
if(h.length()==3){
System.out.println("Hex: 0x"+h);
}else if(h.length()==2){
System.out.println("Hex: 0x0"+h);
}else if(h.length()==1){
System.out.println("Hex: 0x00"+h);
}
Integer d=Integer.valueOf(str,16); //转换为10进制
System.out.println("Decimal: "+d);
String o=Integer.toOctalString(Integer.valueOf(str, 16)); //转换为8进制
if(o.length()==4){
System.out.println("Octal: "+o);
}else if(o.length()==3){
System.out.println("Octal: 0"+o);
}else if(o.length()==2){
System.out.println("Octal: 00"+o);
}else if(o.length()==1){
System.out.println("Octal: 000"+o);
}
}
}
16、10、8进制
最新推荐文章于 2024-04-13 10:01:50 发布