Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
47856 | qc | 统计特定单词数 | C++ | Accepted | 4 MS | 276 KB | 835 | 2023-05-13 16:05:57 |
//#include<bits/stdc++.h> #include <iostream> #include <string> using namespace std; int main() { //reopen("a.in", "r", stdin); //freopen("b.out", "w", stdout); string s, str; int cnt = 0, pos = 0; getline(cin, s); getline(cin, str); for (int i = 0; i < s.size(); i++) { if (s[i] >= 'A' && s[i] <= 'Z') { s[i] += 32; } } for (int i = 0; i < str.size(); i++) { if (str[i] >= 'A' && str[i] <= 'Z') { str[i] += 32; } } s = ' ' + s + ' '; str = ' ' + str + ' '; for (int i = 0; i < str.size(); i++) { int j = 0; for (j = 0; j < s.size(); j++) { if (str[i+j] != s[j]) { break; } } if (j == s.size()) { cnt++; if (cnt == 1) { pos = i; } } } if (cnt == 0) { cout << "-1"; } else{ cout << cnt << " " << pos << endl; } return 0; }