您的位置:首页 > 其它

HDU-4847 Wow! Such Doge!,模拟!

2017-04-01 08:50 260 查看


Wow! Such Doge!

   题意:给定的字符串中doge出现了多少次,直接模拟即可,不用KMP。
char s
;
int main()
{
//    int n;
int ans=0;
while(gets(s))
{
for(int i=0; s[i]!='\0'; i++)
if(s[i]>='A'&&s[i]<'z')
{
if(s[i]=='d'||s[i]=='D')
{
if(s[i+1]=='o'||s[i+1]=='O')
{
if(s[i+2]=='g'||s[i+2]=='G')
{
if(s[i+3]=='e'||s[i+3]=='E')
{
ans++;
i+=3;
}
}
}
}

}
}
printf("%d\n",ans);
return 0;
}


  对于最后没有结果出来,Ctrl+Z即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: