Advertisement
pan7nikt

fibonnaci2

Feb 25th, 2020
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2.     using namespace std;
  3.    
  4.     unsigned input;
  5.     int i;
  6.     int c;
  7.     int A = 1;
  8.     int b;
  9.    
  10.     int fb(int a)
  11.     {
  12.         cout << "0. ";
  13.         cout << "0" << endl;
  14.         cout << "2. "
  15.         cout << "1";
  16.         for (i=2;i<a;i++)
  17.         {
  18.             c = A+b;
  19.             b = A;
  20.             A = c;
  21.             cout << i << ". " << c << endl;
  22.         }
  23.     }
  24.    
  25.    
  26.     int main()
  27.     {
  28.         cout << "podaj ile wyrazow ciagu chcesz wyswietlic: ";
  29.         cin >> input;
  30.         fb(input);
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement