[백준/C++] 10173 - 니모를 찾아서

orangesnail·2025년 5월 5일

백준

목록 보기
100/169

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


전체 코드

이 문제의 핵심은

  1. while (true) 문을 이용해 입력이 "EOI"일때까지 입력받기
  2. find("문자열") 을 이용해 "nemo" 찾기 (이때 조건 분기를 하지 않기 위해 모두 소문자로 변환해준 뒤 찾는게 좋다!)
#include <iostream>
#include <string>
using namespace std;

int main() {
    string input;

    while (true) {
        getline(cin, input);
        if (input == "EOI") break;

        for (int i = 0; i < input.length(); i++) {
            input[i] = tolower(input[i]);
        }

        if (input.find("nemo") != string::npos) cout << "Found" << endl;
        else cout << "Missing" << endl;
    }

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

0개의 댓글