查找第一个串是否是第二个串的子序列;
# include <stdio.h> # include <string.h> # define N 100005 char p[N], t[N]; char check(char *x, char *y) { int lenx, leny, i, j; lenx = strlen(x), leny = strlen(y); if (lenx > leny) return 0; for (i = 0, j = 0; j < leny; ++j) { if (x[i] == y[j]) ++i; if (i == lenx) return 1; } return 0; } int main() { while (~scanf("%s%s", p, t)) { puts(check(p, t) ? "Yes":"No"); } return 0; }
//