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

TOP

返回列表