Advertisement
hegemon88676

Atestat 1

Jan 17th, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. using namespace std;
  4.  
  5. void S1(int &a,int &b)
  6. {
  7.     b=b*10+a%10;
  8.     a=a/10;
  9. }
  10.  
  11. int S2(int k)
  12. {
  13.     int c=0, p=1;
  14.     while(k>0)
  15.     {
  16.         if(k%2==1)
  17.         {
  18.             c=c+(k%10)*p;
  19.             p=p*10;
  20.         }
  21.         k=k/10;
  22.     }
  23.     return c;
  24. }
  25.  
  26.  
  27. int main()
  28. {
  29.     ifstream f("numere.in");
  30.     int n,copie,x;
  31.     f>>n;
  32.     copie=n;
  33.     x=0;
  34.  
  35.     while(copie>0)
  36.         S1(copie,x);
  37.  
  38.     if(S2(x)==n)cout<<"DA";
  39.     else cout<<"NU";
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement