#include<stdio.h>
#include<string.h>
using namespace std;
int BF(char A[], char B[])
{
int i =0, j = 0,count=0;
while (i < strlen(A)&& j < strlen(B) )
{
count++;
//两个字符串均为比较到串尾(只有有一个到串尾就跳出循环)
if (A[i] == B[j])
{
i++;
j++;
}
else {
//匹配失败指针回溯
i = i - j + 1;
j = 0;
}
}
return count;
/*if (j >= B.length()) return i - B.length();
else return count;*/
}
void Next(char T[],int next[]){
int i=1;
next[1]=0;
int j1=0;
while (i<strlen(T)) {
if (j1==0||T[i-1]==T[j1-1]) {
i++;
j1++;
next[i]=j1;
}else{
j1=next[j1];
}
}
}
int KMP(char S[],char T[])
{
int count1=0;
int next[10];
11-23
2711
10-09
458
04-21
3565
08-20
400