Skip to content

Instantly share code, notes, and snippets.

@shaobos
Created June 4, 2014 21:00
Show Gist options
  • Save shaobos/79a13ca266f5275b266e to your computer and use it in GitHub Desktop.
Save shaobos/79a13ca266f5275b266e to your computer and use it in GitHub Desktop.
class Solution {
public:
int reverse(int x) {
int quotient = 0;
int residue = 0;
int reversed_integer = 0;
while (x!=0) {
residue = x%10;
x = x/10;
reversed_integer = reversed_integer * 10 + residue;
}
return reversed_integer;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment