Advertisement
Guest User

Menthetetlne volt a kódod

a guest
Jan 21st, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int a,b,h=0,r,c, i;
  8.     cout << "smaller ";
  9.     cin >> a;
  10.     cout << "bigger ";
  11.     cin >> b;
  12.  
  13.     for (int n = a; n <= b; n++)
  14.     {
  15.         r = n;
  16.         h = 0;
  17.        
  18.         while(r>0)
  19.         {
  20.             c = r % 10;
  21.             r = r / 10;
  22.             h = h*10+c;
  23.         }
  24.         if (n==h)
  25.         {
  26.             int prim = 0;
  27.             for(i = 2; i <= n / 2; i++)
  28.             {
  29.                 if(n % i == 0)
  30.                 {
  31.                     prim = 1;
  32.                     break;
  33.                 }
  34.             }
  35.             if (prim == 0)
  36.             { cout << "#" << n << endl;}
  37.         }
  38.     }
  39.    
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement