Advertisement
STANAANDREY

pb29

Nov 14th, 2018
207
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.  
  3. using namespace std;// ||sau
  4.  
  5. int main() {
  6.  
  7.        unsigned n,ok=1,uc=0,puc=0,nrcif=0;
  8.        cout<<"n=";cin>>n;
  9.        int cn=n;
  10.        while (cn!=0) {
  11.         nrcif++;
  12.         cn/=10;
  13.        }
  14.        while (nrcif!=1&&ok==1) {
  15.         uc=n%10;
  16.         puc=(n/10)%10;
  17.         if (puc!=uc)
  18.               ok=0;
  19.  
  20.         n/=10;
  21.         nrcif--;
  22.        }
  23.  
  24.   if (ok)
  25.    cout<<"DA";
  26.     else
  27.         cout<<"NU";
  28.  
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement