题解 | #字符串字符匹配#

字符串字符匹配

http://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93

#include<stdio.h>
#include<string.h>
int main(){
    char data[200];
    char str[200];
    int num,len,i,j;
    while(scanf("%s",&data)!=EOF){
        scanf("%s",&str);
        num=strlen(data);
        len=strlen(str);
        for(i=0,j=0;i<num&&j<len;){
            if(data[i]==str[j]){
                i++;
                j=0;
            }
            else
                j++;
        }
        if(num==i)
            printf("true\n");
        else
            printf("false\n");
    }
    return 0;
}
全部评论
brilliant!
点赞 回复 分享
发布于 2023-04-11 18:26 山西
666
点赞 回复 分享
发布于 2022-05-19 17:15

相关推荐

评论
10
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务