Shift + Enter · 시작/다시 시작
코드 프롬프트 가이드 읽기
- 프로그래밍 언어
- C++
- 난이도
- 중간
Use a range-based loop to total vector values.
#include <iostream>
#include <vector>
int main() {
std::vector<int> values{4, 8, 15, 16, 23, 42};
int total = 0;
for (int value : values) {
total += value;
}
std::cout << total << '\n';
}