๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm ๐Ÿง‘๐Ÿป‍๐Ÿ’ป/๋ฐฑ์ค€(BOJ)

[๋ฐฑ์ค€,c++] 10822๋ฒˆ - ๋”ํ•˜๊ธฐ

by dkswnkk 2021. 10. 24.
 

10822๋ฒˆ: ๋”ํ•˜๊ธฐ

์ฒซ์งธ ์ค„์— ๋ฌธ์ž์—ด S๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. S์˜ ๊ธธ์ด๋Š” ์ตœ๋Œ€ 100์ด๋‹ค. ํฌํ•จ๋˜์–ด์žˆ๋Š” ์ •์ˆ˜๋Š” 1,000,000๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์€ ์ž์—ฐ์ˆ˜์ด๋‹ค.

www.acmicpc.net

#include <iostream>
#include <vector>
#include <sstream>
#include <string>


using namespace std;
vector<string>v;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    vector<string>v;
    string s; cin >> s;
    string stringBuffer;
    stringstream ss(s);

    while (getline(ss, stringBuffer, ',')) {
        v.push_back(stringBuffer);
    }

    int ans = 0;
    for (int i = 0; i < v.size(); i++) {
        ans += stoi(v[i]);
    }
    cout << ans;




}

๋Œ“๊ธ€