/**
*/
import java.util.Scanner;
public class One{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.println("请输入你要求的十进制值");
int x = sc.nextInt();
System.out.println("你要将十进制数转换为几进制数");
int n = sc.nextInt();
if(n != 2 && n != 8 && n != 16){
System.out.println("请输入有效的进制数(2、8、16)");
return;
}
String str = "";
while(x != 0){
str += String.valueOf(x%n);
x = x/n;
}
char[] chr = str.toCharArray();
for (int i = chr.length-1 ; i >= 0; i--) {
System.out.print(chr[i]);
}
}
}
03-07
796
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
02-28
2474
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-10