KMP模式匹配 三(串)
Time Limit:1000MS Memory Limit:131072KB 64bit IO Format:%lld
& %llu
Description
输入一个主串和一个子串,若匹配成功,则找出匹配的趟数和在子串在主串中的位置,若匹配不成功,则输出0
Input
输入两个字符串
Output
输出匹配的趟数和位置
Sample Input
ababcabcacbab abcac
Sample Output
3 6
#include<iostream> #include<cstring> using namespace std; int a[100000]; char c[10000]; char b[100000]; int main() { int j,n,i,k; cin>>c; cin>>b; a[0]=-1; j=-1; i=0; while(b[i]!='