int phephonatch1(int N){
if(1==N||2==N)
return 1;
else
return php(N-1)+php(N-2);
}
int phephonatch2(int N){
if(N<3)
return 1;
else{
int a = 1;
int b = 1;
for(int i = N;i>3;i--){
b = a+b;
a = b-a;
}
return a+b;
}
}
int main(int argc, _TCHAR* argv[])
{
for(int i = 1;i<=10;i++)
cout<<phephonatch1(i)<<endl;
for(int i = 1;i<=10;i++)
cout<<phephonatch2(i)<<endl;
}
|