标签:blog ar 使用 sp div log as 编程 方法
课后习题1.1.14
编写一个静态方法lg(),接受一个整形参数N,返回不大于log2N的最大整数。不要使用Math库。
public class Test{
public static void main(String[] args){
int i;
i=lg(17,2);
System.out.println(i);
}
public static int lg(int N,int M){
int a = 0;
while(N>=M){
N=N/M;
a++;
}
return a;
}
}
(M为底数)
标签:blog ar 使用 sp div log as 编程 方法
原文地址:http://www.cnblogs.com/m-evan/p/4078403.html