[ create a new paste ] login | about

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

C++, pasted on Dec 13:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <algorithm>
#include <functional>
#include <iterator>
#include <locale>
#include <iostream>

int main()
{
	setlocale(LC_ALL, "");
	int arr[] = {0,1,-5,2,0,-4,3,4,0,5,6,-3,0,7,8,-2,9,10};
	const size_t N = sizeof(arr) / sizeof(arr[0]);

	std::partition(arr, arr+N, std::bind2nd(std::equal_to<int>(), 0));

	typedef std::ostream_iterator<int> O;
	std::copy(arr, arr+N, O(std::cout, " "));

	return 0;
}


Output:
1
0 0 0 0 2 -4 3 4 -5 5 6 -3 1 7 8 -2 9 10 


Create a new paste based on this one


Comments: