package zsy.com;
import java.util.ArrayList;
import java.util.Scanner;
public class Jinzhizhuanhuan {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
System.out.print("Please input the number you want to change:");
int a = in.nextInt();
String b = get_result(change(a));
System.out.println(b);
}
public static ArrayList<Integer> change(int n){
ArrayList<Integer> rs = new ArrayList<Integer>();
int x = 0;
while(n!=0){
x = n % 12;
rs.add(x);
n = n / 12;
}
return rs;
}
public static String get_result(ArrayList<Integer> rs){
int count = rs.size()-1;
String fin = "";
for(int i=count;i>=0;i--){
if(rs.get(i)==10){
fin = fin + "A";
}else if(rs.get(i)==11){
fin = fin + "B";
}else{
fin = fin + rs.get(i);
}
}
return fin;
}
}
运行事例及结果截图: