Problem: Basically Speaking
Description: 16进制以内的转换。
Solution: JAVA中的Integer和String中提供了很多方便的方法,于是偷懒用了JAVA做了。
Code(JAVA):
import java.util.Scanner;
public class Main{
private Scanner cin=new Scanner(System.in);
Main(){
while(cin.hasNext()){
String tmp=cin.next();
int pre_base=cin.nextInt();
int now_base=cin.nextInt();
int pre_num=Integer.parseInt(tmp, pre_base);
String now_num=Integer.toString(pre_num, now_base);
if(now_num.length()>7)
System.out.print(String.format("%7s\n", "ERROR"));
else
System.out.print(String.format("%7s\n", now_num.toUpperCase()));
}
}
public static void main(String[] args) {
new Main();
}
}