码迷,mamicode.com
首页 > 其他好文 > 详细

P59 子序列(All in ALl)

时间:2018-04-17 15:42:34      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:scan   bre   序列   ==   printf   string   style   int   nbsp   

大牛的代码总是让人兴叹(!- !)

#include<stdio.h>
#include<string.h>
char s[100000],t[100000];
int main()
{
    int i,j,k1,k2;
    while(scanf("%s%s",s,t)==2)
    {
        k1=strlen(s);
        k2=strlen(t);
        if(k1>=k2)
        {
            printf("No\n");
            continue;
        }
        for(i=0,j=0;t[j]!=\0&&i<k1;j++)//看看这多个变量作循环的处理。
        {
            if(k1-i>k2-j)
                break;
            if(s[i]==t[j])
                i++;
        }
        if(i==k1)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;    
}

 

P59 子序列(All in ALl)

标签:scan   bre   序列   ==   printf   string   style   int   nbsp   

原文地址:https://www.cnblogs.com/laoyangtou/p/8866937.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!