UVa10340

来源:互联网 发布:软件开发北京 编辑:程序博客网 时间:2024/06/06 23:18

题目链接

分析:
两个指针从前往后扫
当然,还有一种更好的方法:
直接循环t,len作为s的指针,相等时len++,最后比较len和strlen(s)

//这里写代码片#include<cstdio>#include<cstring>#include<iostream>using namespace std;char s[1000010],t[1000010];int main(){    while (scanf("%s%s",&s,&t)!=EOF)    {        int len=0;        for (int i=0;i<strlen(t);i++)            if (s[len]==t[i]) len++;        if (len==strlen(s)) printf("Yes\n");        else printf("No\n");    }    return 0;}