#include <iostream> #include <algorithm> using namespace std; #define ARRAY_SIZE(array) (sizeof(array) / sizeof(*array)) int main() { int iArray[] = {1, 2, 3, 4, 5, 6, 99}; nth_element(iArray, iArray + ARRAY_SIZE(iArray) / 2, iArray + ARRAY_SIZE(iArray)); cout << iArray[ARRAY_SIZE(iArray) / 2] << endl; return 0; }