fork(1) download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. int SPECIAL = 100500;
  5.  
  6. struct less
  7. {
  8. bool operator() (int a, int b)
  9. {
  10. if (a == SPECIAL || b == SPECIAL)
  11. return false;
  12. return a < b;
  13. }
  14. };
  15.  
  16. int main()
  17. {
  18. int a[]= {7, SPECIAL, 3, SPECIAL, 4, SPECIAL, 1, SPECIAL, 4, SPECIAL, 9};
  19. int b[]= {7, 3, 4, 1, 5, 4, 9};
  20.  
  21. std::sort(std::begin(a), std::end(a), less());
  22. std::sort(std::begin(b), std::end(b), less());
  23.  
  24. for (int aa : a) {
  25. std::cout << aa << " ";
  26. }
  27. std::cout << std::endl;
  28.  
  29. for (int bb : b) {
  30. std::cout << bb << " ";
  31. }
  32. std::cout << std::endl;
  33.  
  34. return 0;
  35. }
  36.  
Success #stdin #stdout 0s 3416KB
stdin
Standard input is empty
stdout
1 3 7 100500 100500 4 100500 100500 4 100500 9 
1 3 4 4 5 7 9