알고리즘

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

blueberrysoda 2025. 2. 10. 23:46

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

#include <iostream>
using namespace std;

int main(){
    int T;
    string S;
    cin >> T;
    cin.ignore();
    
    while(T--){
        getline(cin, S);

        int res = 0;
        string tmp = "";

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