Copyright: Attribution, allow others to create paper-based, and must distribute paper (based on the original license agreement with the same license Creative Commons )
Base conversion algorithm improves
time limit: 1.0s memory limit: 256.0MB
description of the problem
the program prompts the user to enter three characters, each of the range is 0-9, AF. The program then will these three characters into the corresponding hexadecimal value, and hexadecimal, decimal, octal output, respectively.
Input formats: Enter only one line, that is three characters.
Output Format: Output a single line, comprising three integers, separated by a space.
O Sample
Sample Input
FFF
sample output
FFF 4095 7777
import java.math.BigInteger;
import java.util.Scanner;
public class 进制转换 {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
String str=in.next();
if(str.equals("000"))
str="0";
BigInteger h=new BigInteger(str,16);
System.out.printf("%s %d %o",str,h,h);
}
}