使用するアルゴリズム std::reduceでvectorの全要素の和を求められます(参考:reduce - cpprefjp C++日本語リファレンス) これをvectorのサイズで割れば平均が求められます。 ちなみに、for文を使ってもOKです。 ソースコード #include <algorithm> #include <iostream> #include <numeric> int main() { // 配列 std::vector<int> v{1, 2, 3, 4, 5, 6}; // 総和を計算 int sum = std::reduce(v.begin(), v.end())…