uva 10340 All in All(子串)

题目大意:给出两个字符串,判断串1是否为串2的子串,这里的子串不要求在串2中连续,但是要保证顺序一致。

解题思路:递归遍历。


#include <cstdio>

int main() {
	char A[100000], B[100000];
	while (scanf("%s%s", A, B) != EOF) {
		int cnt = 0;
		for (int i = 0; B[i]; i++)
			if (B[i] == A[cnt])
				cnt++;

		printf(!A[cnt] ? "Yes\n" : "No\n");
	}
	return 0;
}



你可能感兴趣的:(uva 10340 All in All(子串))