http://www.bnuoj.com/bnuoj/problem_show.php?pid=33647
【题意】:字符串匹配,暴力配就行了
【题解】:截出单词,然后进行匹配就行了
【code】:
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm> using namespace std; char tstr[][]; int main()
{
int t;
scanf("%d",&t);
getchar();
while(t--)
{
char str[];
char ss[];
gets(str);
int len = strlen(str);
int i,j=,k=,flag=;
for(i=;i<len;i++)
{
if(str[i]==' ')
continue;
while(i<len)
{
tstr[j][k]=str[i];
//cout<<str[i];
k++;
i++;
if(i>=len||str[i]==' ')
{
break;
} }
tstr[j][k]='\0';
j++;
k=;
}
// for(i=0;i<j;i++)cout<<tstr[i]<<endl;
int size = j;
int ans = ;
for(i=;i<size;i++)
{
if(strcmp(tstr[i],"u")==||strcmp(tstr[i],"ur")==)
{
ans++;
}
else if(strcmp(tstr[i],"should")==&&i+<size&&strcmp(tstr[i+],"of")==)
{
ans++;
}
else if(strcmp(tstr[i],"would")==&&i+<size&&strcmp(tstr[i+],"of")==)
{
ans++;
}
}
// cout<<tstr[0]<<endl;
for(i=;i<size;i++)
{
int len = strlen(tstr[i]);
for(j=;j<len-;j++)
{
if(tstr[i][j]=='l'&&tstr[i][j+]=='o'&&tstr[i][j+]=='l')
{
ans++;
break;
}
}
}
printf("%d\n",ans*);
}
return ;
}