Example
int A[] = {7, 2, 6, 11, 9, 3, 12, 10, 8, 4, 1, 5};
const int N = sizeof(A) / sizeof(int);
nth_element(A, A + 6, A + N);
copy(A, A + N, ostream_iterator
// The printed result is "5 2 6 1 4 3 7 8 9 10 11 12".
Example
int A[] = {7, 2, 6, 11, 9, 3, 12, 10, 8, 4, 1, 5};
const int N = sizeof(A) / sizeof(int);
nth_element(A, A + 6, A + N);
copy(A, A + N, ostream_iterator
// The printed result is "5 2 6 1 4 3 7 8 9 10 11 12".