Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
57160 | 冯诚阳 | 统计特定单词数 | C++ | Accepted | 3 MS | 276 KB | 547 | 2023-08-26 20:15:42 |
#include<iostream> #include<cstring> using namespace std; int main(){ string s1,s2; int a,s=0,l,w; getline(cin,s1); getline(cin,s2); for (int i=0;i<s1.length();i++){ if (s1[i]>='A'&&s1[i]<='Z') s1[i]=s1[i]+32; } for (int i=0;i<s2.length();i++){ if (s2[i]>='A'&&s2[i]<='Z') s2[i]=s2[i]+32; } s1=' '+s1+' '; s2=' '+s2+' '; w=s2.find(s1); if (w==-1){ cout<<-1<<endl; return 0; } else{ l=s1.length(); a=w; while(a!=-1){ s++; s2.erase(a,l); a=s2.find(s1); } cout<<s<<" "<<w<<endl; return 0; } }