fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int reversedInt(const string &s) {
  5. return stoi(string(s.rbegin(), s.rend()));
  6. }
  7.  
  8. int main() {
  9. string s;
  10.  
  11. while(cin >> s) {
  12. cout << "Normal=" << stoi(s) << endl;
  13. cout << "Reversed=" << reversedInt(s) << endl;
  14. }
  15. return 0;
  16. }
Success #stdin #stdout 0s 3280KB
stdin
001234
56700
stdout
Normal=1234
Reversed=432100
Normal=56700
Reversed=765