작성일 :

문제 링크

10491번 - Quite a problem

설명

각 줄에 ‘problem’이 포함되어 있는지(대소문자 무시) 판단해 yes/no를 출력하는 문제입니다.


접근법

한 줄씩 읽어 소문자로 변환한 뒤 problem이 포함되는지 확인합니다.
포함되면 yes, 아니면 no를 출력합니다.


Code

C#

1
2
3
4
5
6
7
8
9
10
11
using System;

class Program {
  static void Main() {
    string? line;
    while ((line = Console.ReadLine()) != null) {
      var lower = line.ToLower();
      Console.WriteLine(lower.Contains("problem") ? "yes" : "no");
    }
  }
}

C++

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  string line;
  while (getline(cin, line)) {
    for (char& ch : line)
      if ('A' <= ch && ch <= 'Z') ch = ch - 'A' + 'a';
    cout << (line.find("problem") != string::npos ? "yes" : "no") << "\n";
  }

  return 0;
}