fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. string reverse(string::iterator& it)
  6. {
  7. char head=*it;
  8. ++it;
  9. if(head=='b' || head=='w')
  10. return string(1,head);
  11. string upperLeft=reverse(it);
  12. string upperRight=reverse(it);
  13. string lowerLeft=reverse(it);
  14. string lowerRight=reverse(it);
  15.  
  16. return string("x")+lowerLeft+lowerRight+upperLeft+upperRight;
  17. }
  18.  
  19. int main() {
  20. string s="xwwwb";
  21. string::iterator it=s.begin();
  22. it++;
  23. cout<<string(1,*it);
  24. }
Success #stdin #stdout 0s 4564KB
stdin
Standard input is empty
stdout
w