题目链接:P1308 [NOIP2011 普及组] 统计单词数 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
const int N = 1e5+10;
using namespace std;
int a[N];
signed main()
{std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);int sum = 0;string s1,s2;getline(cin,s1);getline(cin,s2);for(int i=0;i<s1.size();i++){s1[i]=tolower(s1[i]);}for(int i=0;i<s2.size();i++){s2[i]=tolower(s2[i]);}s1 = ' '+s1+' ';s2 = ' '+s2+' ';int pos = s2.find(s1);if(pos==string::npos){cout<<-1<<endl;}else{int st = pos;while(st!=-1){sum++;st = s2.find(s1,st+1);}cout<<sum<<' '<<pos<<endl;}return 0;
}