返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int hi(int);
  5. int main()
  6. {
  7.     int x;
  8.     cout<<"請輸入玉推算的費式數列向數:"<<endl;
  9.     cin>>x;
  10.     cout<<"費式數列第"x<<"的值是"<<hi(x)<<endl;
  11.     system("pause");   
  12.     return 0;
  13. }
  14. int hi(int x)
  15. {
  16.     if(x<=1)
  17.         return x;
  18.     else
  19.         return hi(x-1)+hi(x-2);      
  20. }
複製代碼

TOP

返回列表