题意:判断a串是不是b串的子串。
思路:用两根指针分别追踪a,b串。
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
string s,t;;
int flag;
while(cin>>s>>t)
{
int flag=0;
if(s.length()>t.length())
{
flag=0;
}
else{
int i=0;
int j=0;
while(i<s.length()&&j<t.length())
{
if(s[i]!=t[j])
{
j++;
continue;
}
else
{
i++;
if(i==s.length())
{
flag=1;
break;
}
j++;
continue;
}
}
}
if(flag)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}