Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
352297 胡珂 【C5-7】我是第几个单词 C++ 通过 100 5 MS 260 KB 510 2025-09-23 21:36:24

Tests(1/1):


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


测评信息: