Dizzy3113

Untitled

Mar 23rd, 2020
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ///CU FORMULA
  5. /*
  6. int main()
  7. {
  8. ifstream f("numere.in");
  9. int x;
  10. bool gasit=false;
  11. while(f>>x)
  12. if(x%3==1)
  13. {
  14. cout<<x<<" ";
  15. gasit=true;
  16. }
  17. if (gasit==false)
  18. cout<<"nu exista";
  19. }
  20.  
  21. */
  22.  
  23. int main()
  24. {
  25. ifstream f("numere.in");
  26. int x, f1=1, f2=4, f3;
  27. bool gasit=false;
  28. while(f>>x)
  29. {
  30. while(f1<x)
  31. {
  32. f3=2*f2-f1;
  33. f1=f2;
  34. f2=f3;
  35. }
  36. if(f1==x)
  37. {
  38. cout<<x<<" ";
  39. gasit=true;
  40. }
  41. }
  42. if(gasit==false)
  43. cout<<"Nu exista";
  44. }
Advertisement
Add Comment
Please, Sign In to add comment