_what

博客园 首页 新随笔 联系 订阅 管理

Sample Input

sequence subsequence
person compression
VERDI vivaVittorioEmanueleReDiItalia
caseDoesMatter CaseDoesMatter

Sample Output

Yes
No
Yes
No

POJ题目分类 串。
水题, 但Yes错写成YES, No错写成NO WA了好几次
还有,要注意循环如果全部走完,i 最后的值 是 x, 而不是 x - 1
const int maxn = 1e5 + 24;
char a[maxn], b[maxn];

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    while(~scanf("%s%s", a, b)) {
        int x = strlen(a), y = strlen(b);
        int i, j;
        for(i = 0, j = 0; i < x && j < y; j++) i += (a[i] == b[j]);
        if(i == x) puts("Yes");
        else puts("No");
    }

    return 0;
}

 

 
posted on 2019-09-19 20:52  _what  阅读(142)  评论(0编辑  收藏  举报