菲波那切数列

备忘+搜索


#include 
int huo[10000]={0};

using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int search(int a){
	if(huo[a]!=0)  return huo[a];
	else return huo[a]=search(a-2)+search(a-1);

	
	
}
int main(int argc, char** argv) {
	int a;
	cin>>a;
	
	huo[1]=1;
  huo[2]=2;
	cout<

你可能感兴趣的:(菲波那切数列)