摘要: f(n)=f(n-1)+f(n-2)直接使用递归计算:#include<iostream>using namespace std;int count=0; //记录fibo函数调用的次数int fibo(int n){ count++; if(n==0 || n==1){ return 1; }else{ return fibo(n-1)+fibo(n-2); }}int main(){ int n=24; cout<<fibo(n)<<endl; cout<<"fibo函数被调用了"<<count<< 阅读全文
posted @ 2011-11-18 10:34 张朝阳 阅读(495) 评论(0) 推荐(0) 编辑