返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int f(int n)
  5. {
  6.     if(n<=1)
  7.     {
  8.         return n;
  9.     }
  10.     else
  11.     {
  12.         return f(n-1)+f(n-2);
  13.     }
  14. }
  15. int main()
  16. {
  17.     int num;
  18.     cin>>num;
  19.     cout<<f(num)<<endl;
  20.     system("pause");
  21.     return 0;
  22. }
複製代碼

TOP

返回列表