Advertisement
halexandru11

a treia problema

Nov 29th, 2020
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     unsigned int x, prod = 1;
  8.     cin >> x;
  9.     while(x > 0)
  10.     {
  11.         if(x%2 == 1)
  12.         {
  13.             prod = prod * x;
  14.         }
  15.         cin >> x;
  16.     }
  17.     cout << prod << endl;
  18.  
  19.     unsigned int ogl = 0, aux = prod;
  20.     while(aux > 0)
  21.     {
  22.         ogl = ogl*10 + aux%10;
  23.         aux = aux / 10;
  24.     }
  25.  
  26.     if(ogl == prod)
  27.         cout << "Produsul este palindrom";
  28.     else
  29.         cout << "Produsul nu este palindrom";
  30.     return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement