阿摩線上測驗 登入

申論題資訊

試卷:96年 - 96 關務特種考試_四等_資訊處理:程式語言概要#39368
科目:程式語言
年份:96年
排序:0

申論題內容

五、輸入 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