문제 링크: https://www.acmicpc.net/problem/10173
적당히 아무 알고리즘으로나 짜면 됩니다. 문제는 어떻게 이쁘게 짤 것이냐인데..
std::string::find
는 unary predicate밖에 못쓰고, std::find
는 못써먹으니 흐음... 생각을 해봤는데 std::search
라는게 있더라고요. binary predicate을 넣을 수 있는 함수입니다.
참고로 algorithm 헤더에 있습니다
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
string s;
string nemo("nemo");
while (getline(cin, s)) {
if (s == "EOI") break;
cout << (search(s.begin(), s.end(), nemo.begin(), nemo.end(),
[](const char& c1, const char& c2) {return toupper(c1) == toupper(c2); }) != s.end() ? "Found\n" : "Missing\n");
}
return 0;
}
이런식으로 쓰시면 되겠습니다
반응형
'Online Judge > 백준' 카테고리의 다른 글
[백준][C++] 11728: 배열 합치기 (0) | 2020.07.16 |
---|---|
[백준][C++] 10707: 수도요금 (0) | 2020.07.16 |
[백준][C++] 1967: 트리의 지름 (0) | 2020.07.15 |
[백준][C++] 1520: 내리막 길 (0) | 2020.07.14 |
[백준][C++] 19230: Datum (0) | 2020.07.14 |