//Write a function to reverse digits of an integer. E.g. 456 --> 654, -7800 --> -87.
int ReverseDigits (int n){
int ret = 0;
while (n){
ret = ret * 10 + n % 10; //mod 10.
n /= 10; //div
}
return ret;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment