import java.util.Scanner; /** * 输入一个整数,将其转换成八进制数输出 * * @author kif * */ public class Octal { public static void exchange(int number) { StringBuilder strBui = new StringBuilder(); while (number > 0) { strBui.append(number % 8); number /= 8; } System.out.println(strBui.reverse().toString()); } public static void main(String[] args) { Scanner input = new Scanner(System.in); while(true){ System.out.println("请输入一个整数:"); int number = input.nextInt(); Octal.exchange(number); } } }
时间: 2024-10-10 05:42:30