#define MAX_MONTH 13
//函数入口
void digui(void){
int first=0,second=1,month=2,total=0;
total = recursion(first,second,month);
printf("12个月后兔子总数:%d\n",total);
}
//递归调用
int recursion(int first,int second,int month){
if(month >= MAX_MONTH){
return first + second;
} else{
month++;
second = first + second;
first = second - first;
return recursion(first,second,month);
}
}
递归实现Fibonacci数列,布布扣,bubuko.com
原文:http://2842039.blog.51cto.com/2832039/1395635