Skip to content

Instantly share code, notes, and snippets.

@snoopspy
Last active August 29, 2015 14:19
Show Gist options
  • Save snoopspy/5dea94b2697cf2d706fd to your computer and use it in GitHub Desktop.
Save snoopspy/5dea94b2697cf2d706fd to your computer and use it in GitHub Desktop.
#include <iostream>
int reverse_digit(int n) {
int res = 0;
while (n != 0) {
res = res * 10 + (n % 10);
n /= 10;
}
return res;
}
int main() {
using namespace std;
int n;
cin >> n;
cout << reverse_digit(n) << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment