题意:给出两个字符串s和t,判断s是不是t的子串(不用连续)
解析:只需要判断是否匹配不用开数组,所以直接暴力解决.
#include<iostream>
#include<string>
using namespace std;
int main()
{
char s[100005],t[100005];
int i,j,len1,len2;
while(scanf("%s %s",s,t)!=EOF)
{
len1=strlen(s);
len2=strlen(t);
i=0;
j=0;
while(i<len1 && j<len2)
{
if(s[i]==t[j])
{
i++;
j++;
}
else
{
j++;
}
}
if(i==len1)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
return 0;
}