fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int reverse(int a) {
  5. string s = to_string(a);
  6. reverse(begin(s), end(s));
  7. return stoi(s);
  8. }
  9.  
  10. int main(){
  11. int n;
  12. while (cin >> n)
  13. cout << n << " reverse = " << reverse(n) << '\n';
  14. }
Success #stdin #stdout 0s 4380KB
stdin
1 3344 567898
stdout
1 reverse = 1
3344 reverse = 4433
567898 reverse = 898765