Skip to content

Input and Output

1. 문제

문제 확인하기

2. 정답 코드 (C++11)

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    vector<int> numbers;
    int num;
    
    while (cin >> num) {
        numbers.push_back(num);
    }
    
    int sum;
    for (int i = 0; i < numbers.size(); i++) {
        sum += numbers[i];
    }
    
    cout << sum;
    
    return 0;
}