摘要: 【程序1】题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少?1.程序分析: 兔子的规律为数列1,1,2,3,5,8,13,21....f(n)=f(n-2)+f(n-1) 使用递归public static int fib(int n) { if(n==0 || n==1 ) { return 1; } else { return fib(... 阅读全文
posted @ 2014-01-17 00:12 to be crazy 阅读(1542) 评论(0) 推荐(0) 编辑