rt,代码如下
#include<bits/stdc++.h>
using namespace std;
int main()
{
string word,sentence;
getline(cin,word);
getline(cin,sentence);
int len_word=word.size();
int len_sentence=sentence.size();
int count_word=-1,start=0,count_same;
bool is_same=false,have_start=false;
for(int i=0;i<=len_word-1;i++)
{
if(word[i]>='A' and word[i]<='Z')
{
word[i]=char(word[i]+32);
}
}
for(int i=0;i<=len_sentence-1;i++)
{
if(sentence[i]>='A' and sentence[i]<='Z')
{
sentence[i]=char(sentence[i]+32);
}
}
for(int i=0;i<=len_sentence-1;i++)
{
count_word++;
if(word[count_word]==sentence[i])
{
is_same=true;
}
else
{
is_same=false;
count_word=-1;
}
if(count_word==len_word-1)
{
count_word=-1;
if(is_same==true)
{
if(have_start==false)
{
start=i-len_word+1;
have_start=true;
}
count_same++;
}
is_same=false;
}
}
if(count_same==0)
{
cout<<"-1";
return 0;
}
cout<<count_same<<" "<<start;
return 0;
}