算法第四版1.1.14
代码如下
package com.zzh; import edu.princeton.cs.algs4.StdIn; import edu.princeton.cs.algs4.StdOut; public class Test { public static void main(String[] args) { // TODO Auto-generated method stub int n=StdIn.readInt(); StdOut.println(lg(n)); } public static int lg(int n) { int count=0; while(n/2>=1) { n/=2; count++; } return count; } }
勿在浮沙筑高台