問題詳情

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

參考答案

答案:C
難度:簡單0.754673
統計:A(21),B(39),C(323),D(21),E(0)

內容推薦