w2 q2
This commit is contained in:
parent
4c260479dd
commit
453902b44e
4
main.cpp
4
main.cpp
@ -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 {};
|
||||||
|
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);
|
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user