I have made my code to cout the average of the values without the k smallest and k highest. I have a question. Where it says "B' SKELOS" i want to make my code so it cout the average if it replaces the k highest and the k smallest values with their near values. Can you understand the question?
You say that you now compute average of a set from which outliers have been removed. Do you want to compute average for whole set, but only after modifying some elements?
std::sort( array, array+n );
auto sum = std::accumulate( array+k, array+n-k, 0 );
sum += k * (array[k] + array[n-k-1]);
auto avg = static_cast<double>( sum ) / n;