Run ID:34972
提交时间:2022-08-03 14:50:09
#include<iostream> using namespace std; string lwr(string str) { for(int i=0;i<str.length();i++) if(str[i]>='A'&&str[i]<='Z') str[i]+=32; return str; } int main(){ string sp; string str; int cnt=0; int pos=-1; getline(cin,sp); getline(cin,str); str=lwr(str); sp=lwr(sp); str=' '+str+' '; sp=' '+sp+' '; for(int i=0;i<str.length();i++){ int j=0; for(j=0;j<sp.length();j++){ if(str[i+j]!=sp[j]) break; } if(j==sp.length()){ cnt=cnt+1; if(cnt==1)pos=i; } } if(cnt>0) cout<<cnt<<" "<<pos; else cout<<pos; return 0; }