프로그래머스 - 평균 구하기

well-life-gm·2021년 11월 6일
0

프로그래머스

목록 보기
32/125

프로그래머스 - 평균 구하기

배열 합을 구할 때, numeric의 accumulate를 쓰면 편하다.

#include <string>
#include <vector>
#include <numeric>

using namespace std;

double solution(vector<int> arr) {
    return accumulate(arr.begin(), arr.end(), 0.0) / arr.size();
}
profile
내가 보려고 만든 블로그

0개의 댓글