一個簡單求對數的方法來了解方法的定義
???
??? class LogTable
??? {
????? static int lg(int N)
????? {
??????? int i = 0;
??????? while (N > 0)
???????? {
?????????? i++; N/= 2;
???????? }
??????? return i;
????? }
??? public static void main(String[] args)
????? {
??????? for (int N = 1000; N <= 1000000000; N *= 10)
????????? Out.println(lg(N) +""+N);
????? }
???? }
posted on 2006-07-30 10:02
尨奇 閱讀(111)
評論(0) 編輯 收藏 所屬分類:
algorithms in java