1
0
This commit is contained in:
Captain ALM 2022-10-14 12:41:10 +01:00
parent 4c260479dd
commit 453902b44e
Signed by: alfred
GPG Key ID: 4E4ADD02609997B1

View File

@ -41,7 +41,11 @@ int main() {
else else
printlm((v.at(static_cast<vtype>(halfway - 1)) + v.at(static_cast<vtype>(halfway))) / 2.0); printlm((v.at(static_cast<vtype>(halfway - 1)) + v.at(static_cast<vtype>(halfway))) / 2.0);
double avg {}; 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<int>(v.size()); avg /= static_cast<int>(v.size());
printm("The average is: "); printm("The average is: ");
printlm(avg); printlm(avg);