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