nyoj 5

来源:互联网 发布:java编程99乘法表 编辑:程序博客网 时间:2024/05/16 09:34

//nyoj 5

水题,没有什么难度,只是简单的字符匹配,用的是bf算法,也可以用kmp算法

#include
#include
int main(){
 int m,count,i,j;
 char s1[1005],s2[1005];
 scanf("%d",&m);
 while(m--){
  i=0;
  count=0;
  scanf("%s%s",s1,s2);
  while(i
   j=0;
   while(s1[j]==s2[i]&&j
    i++;j++;
  }//bf字符匹配
   if(j==strlen(s1))
    count++;
   i=i-j+1;
  }
  printf("%d\n",count);
 }
 return 0;
}

0 0
原创粉丝点击