五、輸入 34 於下列 getBinary 遞迴程式,請問回傳值為何?(20 分) /** getBinary returns a String representation of the binary * equivalent of a specified integer n. * The worstTime(n) is O(log n).* * @param n – an int in decimal notation. * @return the binary equivalent of n, as a String * @throws IllegalArgumentException, if n is less than 0 */ public static String getBinary (int n) { if (n < 0) throw new IllegalArgumentException( ); if (n <= 1) return Integer.toString (n); return getBinary (n / 2) + Integer.toString (n % 2) } // getBinary
詳解 (共 1 筆)
一起撐住一起上榜
詳解 #6575942
輸入 34 於下列 getBinary...
(共 1868 字,隱藏中)
前往觀看