fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <iterator>
  4.  
  5.  
  6. int main(void){
  7. int A[] = { 19, 9, 1, 7, 11, 3, 2, 21, 4, 6, 8, 12 };
  8. int N = sizeof(A)/sizeof(A[0]);
  9.  
  10. int* mid = std::partition(A, A + N, [](const int& n) {
  11. return ((n % 3) == 0); }
  12. );
  13. std::sort(A, mid);
  14.  
  15. std::sort(mid, A + N, [] (const int& a, const int& b) {
  16. return (a > b);
  17. });
  18.  
  19. int* end = std::remove_if(A, A + N, [](const int& n) {
  20. return ((n % 2) == 0);
  21. } );
  22.  
  23. std::copy(A, end, std::ostream_iterator<int>(std::cout, " "));
  24. return 0;
  25. }
Success #stdin #stdout 0s 3100KB
stdin
Standard input is empty
stdout
3 9 21 19 11 7 1