[백준/C++] 10769 - 행복한지 슬픈지

orangesnail·2025년 8월 26일

백준

목록 보기
160/169

https://www.acmicpc.net/problem/10769


#include <iostream>
#include <string>
using namespace std;

int main() {
    string s;
    getline(cin, s);

    int happy = 0, sad = 0;
    for (int i = 0; i + 2 < (int)s.size(); i++) {
        if (s[i] == ':' && s[i + 1] == '-') {
            if (s[i + 2] == ')') happy++;
            else if (s[i + 2] == '(') sad++;
        } 
    }

    if (happy == 0 && sad == 0) cout << "none" << "\n";
    else if (happy == sad) cout << "unsure" << "\n";
    else if (happy > sad) cout << "happy" << "\n";
    else if (happy < sad) cout << "sad" << "\n";

    return 0;
}
profile
초보입니다. 피드백 환영합니다 😗

0개의 댓글