首页 > 其他 > 详细

二进制字符串匹配

时间:2016-03-26 15:31:55      阅读:268      评论:0      收藏:0      [点我收藏+]

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=5

暴力:

#include <stdio.h>
#include <string.h>

char a[15];
char b[1005];
int len1,len2;

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int i,j;
        int Count=0;
        scanf("%s%s",a,b);
        len1=strlen(a);
        len2=strlen(b);
        for(i=0;i<len2-len1+1;i++)
        {
            for(j=0;j<len1;j++)
            {
                if(a[j]!=b[i+j])
                    break;
            }
            if(j==len1)
                Count++;
        }
        printf("%d\n",Count);
    }
    return 0;
}

 

二进制字符串匹配

原文:http://www.cnblogs.com/TreeDream/p/5322823.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!