diff --git a/main.cpp b/main.cpp index f75ac0e..35776cd 100644 --- a/main.cpp +++ b/main.cpp @@ -41,7 +41,11 @@ int main() { else printlm((v.at(static_cast(halfway - 1)) + v.at(static_cast(halfway))) / 2.0); double avg {}; - for (vtype i = 0; i < v.size(); ++i) avg += v.at(i); + if (v.size() > 2) { + for (vtype i = 1; i < v.size() - 1; ++i) avg += v.at(i); + } else { + for (vtype i = 0; i < v.size(); ++i) avg += v.at(i); + } avg /= static_cast(v.size()); printm("The average is: "); printlm(avg);