編寫函數(shù),其功能為把一個十進制數(shù)轉換為其對應的八進制數(shù)。程序讀入一個十進制數(shù),調(diào)用該函數(shù)實現(xiàn)數(shù)制轉換后,輸出對應的八進制數(shù)。 樣例輸入 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); }}
新聞熱點
疑難解答