nicuvlad76

Untitled

Nov 5th, 2022
729
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath> ///abs= valoare absoluta
  3. using namespace std;
  4.  
  5. int f1, f2, f, n, i; ///variabile globale
  6. int a,b;
  7. ///424
  8. int main()
  9. {
  10.   cin>>a>>b>>n;
  11.   f1=a; f2=b;
  12.   if(n==1){ cout<<f1; return 0;}
  13.  
  14.   cout<<f1<<" "<<f2<<" ";
  15.   f=f1;
  16.   while(abs(f)<=n)
  17.   {
  18.       f=f1+f2;
  19.       f1=f2;
  20.       f2=f;
  21.       if(abs(f)<=n) cout<<f<<" ";
  22.   }
  23.   return 0;
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment