온라인저지
[BOJ] 15904번: UCPC는 무엇의 약자일까?
plzfday
2018. 7. 26. 18:26
https://www.acmicpc.net/problem/15904
이런 문제 좀 재미있다 ㅎㅎ
공백도 받은 방법은 getline(cin, [string])이라는 것도 다시 상기시키는 좋은 계기가 되었다.
#include <string>
#include <iostream>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false), cin.tie(0);
const char al[] = {'U', 'C', 'P', 'C'};
string str;
int idx = 0;
getline(cin, str);
for (auto &i : str)
{
if (idx == 4)
break;
else if (i == al[idx])
idx++;
}
if (idx == 4)
cout << "I love UCPC";
else
cout << "I hate UCPC";
return 0;
}