参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // 定义一个字符串变量来接收进制转换之后的数 String str = ""; // 多组输出测试 while (sc.hasNext()){ str = ""; // 输入 int a = sc.nextInt(); while (a>0) { str = a % 8 + str; a = a / 8; } //输出 System.out.println(str); } } }
0.0分
1 人评分