-
Notifications
You must be signed in to change notification settings - Fork 0
/
1506
46 lines (43 loc) · 936 Bytes
/
1506
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<iostream>
#include<string>
using namespace std;
bool flag,iscontinue;
void ischild(string a, string b, int s, int d) {//a,b串。s,d分别为a,b起始查找位置
if (!flag && iscontinue) {
int lengtha = a.length(), lengthb = b.length();
if (s == lengtha) {
flag = true;
return;
}
if ((lengtha - s) > (lengthb - d))
return;
for (int i = s; i < lengtha; i++) {
bool f = false;
for (int j = d; j < lengthb; j++) {
if (a[i] == b[j] && iscontinue) {
f = true;
if (i + 1 == lengtha)
flag = true;
else if (j + 1 == lengthb)
return;
else ischild(a, b, i + 1, j + 1);
}
}
if (!f) iscontinue = false;
}
}
}
int main()
{
static string str1, str2;
while (cin >> str1 >> str2) {
flag = false; iscontinue = true;
ischild(str1, str2, 0, 0);
if (flag)
cout << "Yes" << endl;
else cout << "No" << endl;
}
cout << endl;
system("pause");
return 0;
}