进制转化
进制转换
https://www.nowcoder.com/practice/2cc32b88fff94d7e8fd458b8c7b25ec1?tpId=117&tags=&title=&diffculty=0&judgeStatus=0&rp=1&tab=answerKey
//除留取余法 public String solve (int M, int N) { int flag = 0; //考虑M为负数的情况 if(M<0) { M = -M; flag = 1; } // write code here StringBuilder sb = new StringBuilder(); while(M!=0){ int ys = M%N; M = M/N; char t = '0'; if(ys<10) t = (char)(t+(ys-0)); else t = (char)('A'+(ys-10)); sb.append(t); } String ress = sb.reverse().toString(); return flag==1?"-"+ress:ress; }