标签:
解题思路:
1 public int exp(int month){ 2 if(month == 1 || month == 2){ 3 return 1; 4 }else{ 5 return exp(month-1)+exp(month-2); 6 } 7 } 8 @Test 9 public void testExp(){ 10 Formatter f = new Formatter(System.out); 11 for(int i = 1;i < 21;i++){ 12 f.format("%-10s",exp(i)+" "); 13 if(i%5==0){ 14 f.format("%-10s\n",exp(i)); 15 } 16 } 17 }
测试结果:
1 1 2 3 5 5
8 13 21 34 55 55
89 144 233 377 610 610
987 1597 2584 4181 6765 6765
标签:
原文地址:http://www.cnblogs.com/JamKong/p/4908573.html