fork(2) download
  1. #include <algorithm>
  2. #include <iterator>
  3. #include <iostream>
  4.  
  5. int arr[] = {0, -2, 4, 0, 19, 69};
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. copy(begin(arr), end(arr), ostream_iterator<int>(cout, " "));
  12. // partition
  13. partition(begin(arr), end(arr), [&](int n) { return n!=0; });
  14. cout << "\n";
  15. copy(begin(arr), end(arr), ostream_iterator<int>(cout, " "));
  16. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
0 -2 4 0 19 69 
69 -2 4 19 0 0