子序列(All in all), UVa 10340
程序员文章站
2022-04-27 23:40:43
...
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
int main()
{
string s, t;
while (cin >> s && cin >> t)
{
int lent = s.length();
int is_sub = 1;
long long currentpos = 0;
for (int i = 0; i < lent; ++i)
{
if ((currentpos = t.find(s[i], currentpos)) == string::npos)
{
is_sub = 0;
break;
}
++currentpos;//t数组中索引后移一位
}
if (is_sub == 0)
cout << "No" << endl;
else
cout << "Yes" << endl;
}
}
下一篇: 怎样预防游泳后耳鸣 游泳后耳鸣怎么办