题目
import java.util.Scanner;public class Main {public static void main(String[] args) {//将十进制数M转化为N进制数Scanner sc = new Scanner(System.in);int m = sc.nextInt();int n = sc.nextInt();StringBuffer sb = new StringBuffer();//1String s = "0123456789ABCDEF";//2boolean f = false;//3//考虑十进制数字M是否为0if(m == 0) {sb.append('0');}else if(m<0) {m = -m;f = true;}while(m!=0) {sb.append(s.charAt(m%n));m/=n;}if(f) {sb.append("-");}System.out.println(sb.reverse().toString()); }
}