传送门:http://acm.jlu.edu.cn/joj/showproblem.php?pid=2098
题意:判断一个字符串A是否出现在B中,并且A可以不连续。
思路:将B字符串从头到尾扫一遍,标签i指向A的首位,如果当前B位置的字符与A[i]一样,i++。最后判断i和A.length是否相等。
代码:
#include <stdio.h>
#include <string.h>
char s[100000],t[100000];
int main()
{
memset(s,0,sizeof(s));
memset(t,0,sizeof(t));
while (scanf("%s%s",s,t)!=EOF)
{
int k=0,count=0;
int len1=strlen(s);
int len2=strlen(t);
for (int i=0;i<len2;++i)
{
if (count<len1)
{
if (t[i]==s[count])
count++;
}
else
break;
}
if (count==len1) printf("Yes\n");
else printf("No\n");
}
return 0;
}