int select(int left,int right,int k) { int count; int pivotIndex = (left + right) / 2; int pivotNewIndex = partition(left, right, pivotIndex, &count); if (k == pivotNewIndex) return pole[k]; else if (k < pivotNewIndex) return select(left, pivotNewIndex-1, k); else return select(pivotNewIndex+1, right, k); }