fork download
  1. #include <algorithm>
  2. #include <functional>
  3. #include <iostream>
  4. #include <iterator>
  5. #include<cstring>
  6.  
  7. bool is_vowel(char ch) { return std::strchr("aeiouAEIOU", ch) != NULL ; }
  8.  
  9. int main()
  10. {
  11. std::string s("A quick brown Fox jumps over a Lazy DOG.");
  12.  
  13. std::cout << "Original vector:\n ";
  14. std::copy(s.begin(), s.end(),
  15. std::ostream_iterator<char>(std::cout, " "));
  16.  
  17. // Partition the vector
  18. std::string::const_iterator p =
  19. std::partition(s.begin(), s.end(),
  20. std::ptr_fun(is_vowel));
  21.  
  22. std::cout << "\nPartitioned vector:\n ";
  23. std::copy(s.begin(), s.end(),
  24. std::ostream_iterator<char>(std::cout, " "));
  25.  
  26. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
Original vector:
    A   q u i c k   b r o w n   F o x   j u m p s   o v e r   a   L a z y   D O G . 
Partitioned vector:
    A O a u i a e o u o o w n   F r x   j b m p s     v k r   c   L q z y   D   G .