編寫函數,其功能為把一個十進制數轉換為其對應的八進制數。程序讀入一個十進制數,調用該函數實現數制轉換后,輸出對應的八進制數。 樣例輸入 9274 樣例輸出 22072樣例輸入 18 樣例輸出 22import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); String num = Integer.toOctalString(n); System.out.PRintln(num); }}
新聞熱點
疑難解答