double averageExceptMaxMin(SinglyList &list) //去掉最高分和最低分,再求平均值
double averageExceptMaxMin(SinglyList &list)
{
double d = 0.0;
int n = 0;
double max = 0.0;
double min = 0.0;
Node * node = &list.head;
while (node != NULL)
{
d += node->value;
n++;
if (max < node->value) max = node->value;
if (min > node->value) min = node->value;
node = node->next;
}
return (d - max - min) / (double)(n - 2);
}
其中具体和你链表有关的细节你照着修改下。