fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. int main()
  5. {
  6. int arr[] = {4, 7, 3, 5, 6, 2, 9, 1, 10, 8};
  7.  
  8. for(int value: arr)
  9. std::cout << value << ' ';
  10. std::cout << std::endl;
  11.  
  12. std::stable_partition(arr, arr+10, [&arr](int a){ return (a < arr[0]); });
  13.  
  14. for(int value: arr)
  15. std::cout << value << ' ';
  16. std::cout << std::endl;
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
4 7 3 5 6 2 9 1 10 8 
3 2 1 4 7 5 6 9 10 8