UVA - 10340 All in All

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


解题思路:循环遍历即可

#include <cstdio>

int main() {
	char s1[100000], s2[100000];
	while (scanf("%s%s", s1, s2) != EOF) {
		int cnt = 0;
		for (int i = 0; s2[i] != '\0'; i++)
			if (s1[cnt] == s2[i])
				cnt++;
		printf(s1[cnt] == '\0' ? "Yes\n" : "No\n");
	}
	return 0;
}


你可能感兴趣的:(UVA - 10340 All in All)