SHARE
TWEET

[ćw 2 / 1] Ciąg Fibbonacciego

wrahq Apr 23rd, 2019 (edited) 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Zadeklaruj tablice o rozmiarze 100. Wypelnij tablice zgodnie z regulami Ciagu Fibbonacciego
  2. (pierwszy i drugi element = 1, kazdy nastepny to suma dwóch poprzednich: 1,1,2,3,5,8, itd.).
  3.    
  4.  
  5. #include<iostream>
  6. using namespace std;
  7.  
  8. int main(){
  9. cout << "Ciag Fibbonacciego" << endl << endl;
  10.    
  11.     long long int* tab = new long long int[100];
  12.     tab[0] = 1;
  13.     tab[1] = 1;
  14.    
  15.     cout << tab[0] << endl;
  16.     cout << tab[1] << endl;
  17.    
  18.     for(int i = 2; i<=100; i++){
  19.         tab[i] = tab[i-1] + tab[i-2];
  20.         cout << tab[i] << endl;
  21.     }
  22.    
  23.     cin.get();
  24.    
  25. return 0;
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top