Asa's Website

A - Finding a Word

cpaojitp1

最終更新日

Table of Contents

Loading...

問題

https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/9/ITP1_9_A

問題文

TT の中に WW はいくつ含まれるか数えてね。

制約

サンプル

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 でそのまましちゃっていい。
あとはやるだけ。

コード

https://onlinejudge.u-aizu.ac.jp/status/users/a01sa01to/submissions/1/ITP1_9_A/judge/6370890/C++17

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; }