Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int tab[30],n=0,wynik=0,i=0;
  8. cout << "Podaj n: " << endl;
  9. cin >> n;
  10. for(i=0; i<=n; i++)
  11. {
  12. tab[i]=i;
  13. if(( i!=0)&&(i!=1))
  14. {
  15. wynik=tab[i-1]+tab[i-2];
  16. }
  17. else if(tab[i]==0) wynik=0;
  18. else if (tab[i]==1) wynik=1;
  19. cout << tab[i] << "element ciagu Fibonacciego to: " << wynik << endl;
  20. }
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement