Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
3523 孙浚轩 统计特定单词数 C++ Wrong Answer 0 MS 268 KB 832 2024-06-14 23:40:50

Tests(2/11):


Code:

#include<iostream> using namespace std; void allToLC(string &s){ int lens=s.size(); for(int i=0;i<lens;i++) if(s[i]>='A'&&s[i]<='Z') s[i]+=32; } int main(){ string word,essay; cin>>word; cin.get(); getline(cin,essay); allToLC(word); allToLC(essay); int lenw=word.size(),lens=essay.size(),frequency=0,first,temp; bool d=0,d2=0; for(int i=0,cnt=0;i<lens;i++){ if(!d) temp=i; if(essay[temp+cnt]==word[cnt]){ if(!d) d=1; if(cnt==lenw-1){ if(essay[temp+cnt+1]==' '){ if(!d2) first=temp,d2=1; frequency++,d=0,cnt=0; } }else cnt++; }else cnt=0,d=0; } if(d2) cout<<frequency<<" "<<first; else cout<<-1; return 0; }


Run Info:

------Input------
alun Alun a l u n alu n aluN
------Answer-----
2 0
------Your output-----
1 0