fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. int main()
  6. {
  7. std::vector<double> v = { 4.5, 2.5, 5.5, 6.5, 3.5 };
  8.  
  9. auto part = std::partition(v.begin(), v.end(), [](double d){return 4 < d && d < 7;});
  10.  
  11. for (auto it = std::begin(v); it != part; ++it)
  12. std::cout << *it << "\n";
  13. }
  14.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
4.5
6.5
5.5