#include <iostream>
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <iomanip>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
using namespace std;
#define INF 0x3f3f3f3f
#define maxn 110000
const double PI = acos(-1.0);
typedef long long ll;
int Next[maxn];
char a[1000];
void get_next(char a[]);
int KMP(char a[], char b[]);
int main()
{
char b[maxn] ;
char a[maxn];
while(cin >> a >> b)
{
int sum = KMP(a, b);
cout << sum << endl;
}
return 0;
}
void get_next(char a[])
{
int i = 0, j = -1;
Next[0] = -1;
while(a[i] != '\0')
{
if(j == -1 || a[i] == a[j])
{
i++;
j++;
Next[i] = j;
}
el
KMP算法求模式串在原串中出现的次数
最新推荐文章于 2022-10-21 22:28:27 发布