알고리즘

[알고리즘] 백준 10822 - 더하기 (C++)

blueberrysoda 2024. 9. 27. 23:53

[문제 링크] : https://www.acmicpc.net/problem/10822

#include <iostream>
using namespace std;

int main(){
    string S, T;
    int sum = 0;
    cin >> S;

    for(int i=0; i<S.size(); i++){
        if(S[i] == ','){
            sum += stoi(T);
            T = "";
        }
        else{
            T += S[i];
        }
    }
    cout << sum + stoi(T) << "\n";
    return 0;
}