Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
34547 | 邓欣荣 | 统计特定单词数 | C++ | Accepted | 5 MS | 764 KB | 698 | 2022-08-03 09:56:39 |
#include<iostream> #include<cstdlib> #include<cstdio> #include<cstring> 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,str; int cnt=0,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; }