a53

Impare_Bac

a53
Jul 15th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. void Impare(int &n)
  2. {
  3. int aux=0, p=1, c;
  4. while(n>10)
  5. {
  6. c=n%10;
  7. if(c%2)
  8. c--;
  9. aux=aux+p*c;
  10. p=p*10;
  11. n/=10;
  12. }
  13. if(n%2==0)
  14. aux=aux+p*n;
  15. else if(n>1)
  16. aux=aux+p*(n-1);
  17. n=aux;
  18. }
Add Comment
Please, Sign In to add comment