返回列表 發帖
哈哈我第一個!
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main(void){
  5.    
  6.     int x;
  7.    
  8.     cout << "Please enter a number: " ;
  9.     cin >> x;
  10.    
  11.     long n[x];
  12.     n[0] = 1;
  13.     n[1] = 1;
  14.     n[2] = 0;
  15.    
  16.     cout << "1" << endl;
  17.     cout << "1" << endl;
  18.    
  19.     for(int i = 2; i < x; i++){
  20.             n[i] = n[i-2] + n[i -1];
  21.             cout << n[i] << endl;
  22.     }
  23.    
  24.     system("pause");
  25.     return 0;
  26. }
複製代碼

TOP

返回列表