Now that it's solved, I guess I can show this:
Code:
#include <istream>
#include <limits>
#include <algorithm>
float jck::FindAverage(std::istream& input) {
long count = 0L;
float sum = 0.0;
float highest = std::numeric_limits<float>::min();
float lowest = std::numeric_limits<float>::max();
float value;
while (input >> value) {
highest = std::max<float>(value, highest);
lowest = std::min<float>(value, lowest);
sum += value;
++count;
}
return (sum - highest - lowest) / (count - 2L);
}
Just showing what's possible. You can do a lot in a few lines if you just stop and think. ... And use a few functions to simplify logic (even if you have to make your own).