fork download
  1. #include <vector>
  2. #include <iostream>
  3. #include <algorithm>
  4.  
  5.  
  6. int main() {
  7. // Sort a vector of ints so that even numbers are on the
  8. // left and odd numbers are on the right
  9. std::vector<int> foo {1, 2, 3, 4, 5};
  10. std::partition( foo.begin(), foo.end(), [](int x) { return x % 2 == 0; } );
  11. for(auto &x : foo) std::cout << x << " ";
  12. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
4 2 3 1 5