fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <iterator>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. int main ()
  9. {
  10. vector<int> A {1, 3, 5, 7};
  11. vector<int> B {0, 2, 4, 6};
  12. vector<int> C;
  13. if (!is_sorted( begin(A), end(A) )) reverse( begin(A), end(A) );
  14. if (!is_sorted( begin(B), end(B) )) reverse( begin(B), end(B) );
  15. merge( begin(A), end(A), begin(B), end(B), back_inserter<vector<int>>( C ) );
  16. for (auto x : C) cout << x << ", ";
  17. return 0;
  18. }
Success #stdin #stdout 0s 3032KB
stdin
Standard input is empty
stdout
0, 1, 2, 3, 4, 5, 6, 7,