Created
March 6, 2017 09:38
-
-
Save swshan/d322e4389cda4edac081be147bac2ef1 to your computer and use it in GitHub Desktop.
算法4书本练习 1.1.14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
// 给一个N的正帧数 返回不大于Log2N的最大整数 | |
public class Log { | |
public static int lg(int N) { | |
double log2n = N / 2; // base is 2 | |
int result = 1; | |
while ( result < log2n) { | |
result++; | |
} | |
return result; | |
} | |
public static void main(String[] args) { | |
int number = Log.lg(10); | |
System.out.println(number); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
你这结果错了