Advertisement
icatalin

Problema lucrata in clasa 3.12 palindrom

Dec 3rd, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. //Introduceti un sir de numere pana cand este introdusa valoarea 0 si afisati cate numere din acestea sunt panlindroame
  2.  
  3.  
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     int cx,x,ogl,nr,c;
  11.     cout<<"x= "; cin>>x;
  12.     nr= 0;
  13.  
  14.     while (x)
  15.     {
  16.         cx=x;
  17.         ogl=0;
  18.         while (cx)
  19.         {
  20.             c=cx%10;
  21.             cx=cx/10;
  22.             ogl=ogl*10 +c;
  23.  
  24.         }
  25.  
  26.         if (x==ogl)
  27.         nr++;
  28.         cout<<"x= "; cin>>x;
  29.  
  30.     }
  31.     cout<<"nr= "<<nr<<endl;
  32.     return 0;
  33.  
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement