자라는 개발자/문제풀이

백준 c++ 15904 UCPC는 무엇의 약자일까?

자란다 2022. 3. 9. 23:19
728x90
반응형

15904 UCPC는 무엇의 약자일까?


문제풀이

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
void fast_io(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int main(void)
{
    fast_io();
    string str, res = "UCPC";
    int cnt = 0;
    getline(cin, str);
    for (int i = 0; i < str.length(); i++)
    {
        if (str[i]==res[cnt])
            cnt++;
    }
    if (cnt<4)
        cout << "I hate UCPC";
    else
        cout << "I love UCPC";
}

어찌됐든 순서대로 UCPC 가 들어있으면 된다.

728x90
반응형

'자라는 개발자 > 문제풀이' 카테고리의 다른 글

백준 c++ 2847 게임을 만든 동준이  (0) 2022.03.11
백준 c++ 9237 이장님 초대  (0) 2022.03.10
백준 c++ 1449 수리공 항승  (0) 2022.03.08
백준 c++ 11047 동전 0  (0) 2022.03.06
백준 c++ 4796 캠핑  (0) 2022.03.05