Skip to content

Latest commit

 

History

History
25 lines (23 loc) · 544 Bytes

File metadata and controls

25 lines (23 loc) · 544 Bytes
#include <iostream>
using std::cin; using std::cout; using std::endl; using std::cerr;
#include <string>
using std::string;
#include <sstream>
using std::istringstream;
#include <vector>
using std::vector;
#include <numeric>

int main() {
    cout << "Please type the number for vector<int>: " << endl;
    string tmp;
    getline(cin, tmp);
    istringstream iss(tmp);
    vector<int> vi;
    int i;
    while (iss >> i)
        vi.push_back(i);
    int sum = std::accumulate(vi.cbegin(), vi.cend(), 0);
    cout << sum << endl;
}