-
POJ 938/UVA 10340-All in All(全在其中)
-
题目链接:10340 - All in All
-
思路:
题目大意是给两个字符串s t,如果t是在s的基础上插入若干个其他字符串,输出Yes,否则输出No
只要s的字符全部出现在t中,t就是符合要求的字符串
更正:图中-如果t分别在s中 改为--如果s分别在t中
-
代码:
#include<iostream>
#include<cstring>
using namespace std;
//POJ NO.938
#define MAX_Length 100005
char s[MAX_Length], t[MAX_Length];
int main()
{
while (cin >> s >> t)
{
int len1 = strlen(s);
int len2 = strlen(t);
int len = 0;
int Judge = 0;
int i, j;
for (i = 0, j = 0; i < len1&&j < len2; j++)
{
if (s[i] == t[j])
i++;
}
if (i == len1)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}