Advertisement
Guest User

Untitled

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