提交时间:2025-03-02 19:51:57
运行 ID: 310949
#include<bits/stdc++.h> using namespace std; int main() { string str, word; int count = 0; getline(cin, str, '.'); cin >> word; for (int i = 0; i < str.size(); i++) { int j = i; while (j < str.size() && str[j] != ' ') { j++; } count++; if (str.substr(i, j - i) == word) { cout << count << endl; return 0; } i = j; } cout << str.size() - 1 << endl; return 0; }