fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. extern bool dbg1 = true; // enable diagnostics / debug
  7. extern bool dgb2 = false; // things for debug, but not this build
  8.  
  9. string reverse(string);
  10.  
  11. int main() {
  12. cout << reverse("1234") << endl;
  13.  
  14. } // end main
  15.  
  16. string reverse(string integer) {
  17. if (integer.length() == 0)
  18. return "";
  19. else
  20. return reverse(integer.substr(1, integer.length())) + integer.substr(0,1);
  21. } // end reverse
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
4321