fork(2) download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4. #include <locale>
  5.  
  6. int main() {
  7.  
  8. using namespace std;
  9. using namespace std::placeholders;
  10.  
  11. typedef std::string String;
  12. typedef String::value_type char_type;
  13.  
  14. String input = "how are you";
  15. locale default_locale;
  16.  
  17. auto is_graph = bind( isgraph<char_type>, _1, cref(default_locale) );
  18. auto is_digit = bind( isspace<char_type>, _1, cref(default_locale) );
  19.  
  20. for( String::iterator rev_begin = input.begin(), rev_end;
  21. rev_begin != input.end(); rev_begin = rev_end ) {
  22.  
  23. rev_begin = find_if( rev_begin, input.end(), is_graph );
  24. rev_end = find_if( rev_begin, input.end(), is_digit );
  25.  
  26. if( rev_begin == input.end() )
  27. break;
  28.  
  29. reverse( rev_begin, rev_end );
  30. }
  31.  
  32. cout << input << endl;
  33. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty