Advertisement
double_trouble

Alyona2

Apr 8th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. bool check(int x)
  9. {
  10.     while (x > 0)
  11.     {
  12.         if (x % 10 == 3)
  13.             return true;
  14.         x /= 10;
  15.     }
  16.     return false;
  17. }
  18.  
  19. int main()
  20. {
  21.     cout << "Enter N" << endl;
  22.     int n;
  23.     cin >> n;
  24.  
  25.     int a1 = 1, a2 = 1;
  26.     while (a2 < n)
  27.     {
  28.         if (check(a2))
  29.             cout << a2 << " ";
  30.         int new_a1 = a2;
  31.         int new_a2 = a1 + a2;
  32.         a1 = new_a1;
  33.         a2 = new_a2;
  34.     }
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement