daily pastebin goal
34%
SHARE
TWEET

Untitled

a guest Jan 20th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <limits.h>
  3. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  4.  
  5. using namespace std;
  6. int fibonacci(int n)
  7. {
  8. int a; 
  9.     int b;
  10.     int c;
  11.    
  12.     if((n==1)||(n==0))
  13.     {
  14.         return(n);
  15.     }
  16.     else
  17.     {
  18.     c=fibonacci(n-2);  
  19.     b=fibonacci(n-1);
  20.         a=b+c;
  21.         if (a<b||a<=c){
  22.         return 0;
  23.         system("pause");
  24.     }
  25.         return a;
  26.     }
  27. }
  28. int main(int argc, char** argv) {
  29.     int n,i=0;
  30.     int fib;
  31.     cout<<"Ile liczb fibonacciego mam wypisac? ";
  32.     cin>>n;
  33.     cout<<"Liczby :"<<endl;
  34.  
  35.     while(i<n||(fib!=0 &&i !=0))
  36.     {
  37.     fib=fibonacci(i);
  38.         cout<<i+1<<". ";
  39.        
  40.         cout<<fib<<endl;
  41.         i++;
  42.  
  43.     }
  44.  cout<<" ERROR : WARTOSC WYKRACZA POZA INTEGERA"<<endl;
  45.     return 0;
  46. }
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