問題
https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/9/ITP1_9_A (新しいタブで開く)
問題文
の中に はいくつ含まれるか数えてね。
制約
- は英小文字からなる
- の 1 行当たりの文字数は 以下
サンプル
I/O 1
computer Nurtures computer scientists and highly skilled computer engineers who will create and exploit knowledge for the new era Provides an outstanding computer environment END_OF_TEXT
3
考察
単語を数えるので、 cin
でそのまましちゃっていい。
あとはやるだけ。
コード
int main() { string w, t; int ans = 0; cin >> w; transform(w.begin(), w.end(), w.begin(), ::tolower); while (true) { cin >> t; if (t == "END_OF_TEXT") break; transform(t.begin(), t.end(), t.begin(), ::tolower); if (t == w) ++ans; } cout << ans << endl; }