c++实现一个打分算法(去掉最低分和最高分求平均值)

#include
using namespace std;
const int StuNum = 10;
double countavergescore(double * arr, int n);
int main()
{
double arr[StuNum];
cout << "Please enter " << StuNum << " specilist sores:\n";
int i = 0;
while (i < StuNum)
{
cin >> arr[i++];
cin.get();
}
cout << "\nThe averge sore is :" << countavergescore(arr, StuNum) << "\n";
return 0;
}
double countavergescore(double * arr, int n)
{
double max = arr[0];
double min = arr[0];
double sum = arr[0];
int i = 1,j=1;
for (; i {
sum += arr[i];
if (arr[i]>max)
max = arr[i];
}
for (; j {
if (arr[j] min = arr[j];
}
sum -= max;
sum -= min;
return sum / (n - 2);
}

    推荐阅读