Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
310949 | 韩雨航 | 【C5-7】我是第几个单词 | C++ | 通过 | 100 | 1 MS | 248 KB | 512 | 2025-03-02 19:51:57 |
#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; }