Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n, n1, n2, c, p1, p2;
  8.     cin>>n;
  9.     n1=0; p1=1;
  10.     n2=0; p2=1;
  11.     while(n!=0)
  12.     {
  13.         c=n%10;
  14.         if(c%2==0)
  15.         {
  16.             n1=n1+c*p1;
  17.             p1=p1*10;
  18.         }
  19.         else
  20.         {
  21.             n2=n2+c*p2;
  22.             p2=p2*10;
  23.         }
  24.         n=n/10;
  25.     }
  26.     if(n1>n2) cout<<n1-n2;
  27.     if(n2>n1) cout<<n2-n1;
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement