[ create a new paste ] login | about

Link: http://codepad.org/I6485Ozy    [ raw code | output | fork ]

C++, pasted on Sep 22:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <algorithm>
#include <iterator>
#include <iostream>
#include <functional>

int main() {
  int arr[] = { -1, 2, 4, 5, -4, -6, 3, -4 };
  
  std::stable_partition(arr, arr + sizeof(arr) / sizeof(arr[0]), std::bind2nd(std::less<int>(), 0));
  
  std::copy(arr, arr + sizeof(arr) / sizeof(arr[0]), std::ostream_iterator<int>(std::cout, " "));
  
  return 0;
}


Output:
1
-1 -4 -6 -4 2 4 5 3 


Create a new paste based on this one


Comments: