Advertisement
rotti321

BAC2019 martie SIII ex 1

Mar 31st, 2022
36
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. int main() {
  6. // ifstream cin("test.in");
  7. // ofstream cout("test.out");
  8. int x,u,z,dif,nr=0,p=1;
  9. cin>>x; //x=7255
  10. while(x>9){
  11. u=x%10;
  12. z=x%100/10;
  13. if(z>u){
  14. dif=z-u;
  15. }
  16. else{
  17. dif=u-z;
  18. }
  19. nr=nr+u*p;
  20. p=p*10;
  21. nr=nr+dif*p;
  22. p=p*10;
  23. x=x/10;
  24. }
  25.  
  26. nr=nr+x*p;
  27. cout<<nr;
  28.  
  29.  
  30. return 0;
  31. }
  32.  
Advertisement
RAW Paste Data Copied
Advertisement