#include<iostream>
#include<string>
using namespace std;
int main()
{
string s, t;
while (cin >> s >> t)
{
int lens, lent, i, j;
lens = s.size();
lent = t.size();
i = j = 0;
while (i<lens)
{
while (j < lent && t[j] != s[i])
j++;
if (j == lent)
break;
i++;
}
if (i == lens && lens!=lent)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}
这是POJ上的1936题,判断s是否为t的子串,我试了好几次都没问题,但是提交上去
又不对;我以为s和t不能完全相同,于是在输出"Yes"的判断条件里面又加上了长度必须相等,但还是不对,有谁知道问题所在吗?