알고리즘

[알고리즘] 백준 10769 - 행복한지 슬픈지 (C++)

blueberrysoda 2024. 12. 3. 23:08

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

#include <iostream>
using namespace std;

int main(){
    string S;
    int A = 0, B = 0;

    getline(cin, S);
    for(int i=0; i<S.size()-2; i++){
        if(S[i] == ':' && S[i + 1] == '-'){
            if(S[i + 2] == ')'){
                A++;
            }
            else{
                B++;
            }
        }
    }

    if(A == 0 && B == 0){
        cout << "none\n";
    }
    else if(A == B && A){
        cout << "unsure\n";
    }
    else{
        if(A > B){
            cout << "happy\n";
        }
        else{
            cout << "sad\n";
        }
    }
    return 0;
}