Untitled
#include <iostream> using namespace std; void reverse(int a) { int rev = 0; while (a != 0) { int digit = a % 10; rev = rev * 10 + digit; a /= 10; } cout << rev << endl; } int main() { int b; cin >> b; reverse(b); return 0; }
Leave a Comment
#include <iostream> using namespace std; void reverse(int a) { int rev = 0; while (a != 0) { int digit = a % 10; rev = rev * 10 + digit; a /= 10; } cout << rev << endl; } int main() { int b; cin >> b; reverse(b); return 0; }