Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
3440 | 邓小龙 | 统计特定单词数 | C++ | Wrong Answer | 0 MS | 260 KB | 921 | 2024-06-08 10:44:58 |
# include<iostream> # include<cstring> using namespace std; string lwl(string s){ int len_s=s.size(); for(int i=0;i<len_s;i++){ if(s[i]>='A'&&s[i]<='Z') s[i]=s[i]+32; } return s; } int main(){ string s1,s2; getline(cin,s1); getline(cin,s2); s1=lwl(s1); s2=lwl(s2); int len_s1=s1.size(),len_s2=s2.size(),cnt=0,pos; pos=s2.find(s1); if(pos<len_s2){ int poss=pos; while(1){ cnt++; poss=poss+len_s1; //if(poss>=len_s2) break;//超出了s2范围,结束 string temp=s2.substr(poss,len_s2-poss); if(temp.find(s1)>=len_s2)break;//超出了s2范围,结束 poss=poss+temp.find(s1); //cout<<poss<<endl; } } else{ cout<<-1<<endl; return 0; } cout<<cnt<<" "<<pos<<endl; return 0; }
------Input------
alun A lun is the best teacher of TCJY
------Answer-----
-1
------Your output-----
1 -1