简单的KMP
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
string strI = "";
string strII = "";
cin >> strI >> strII;
int lengthI = strI.length();
int lengthII = strII.length();
int now = 0;
int j = 0;
while(lengthI--) {
for (int i=0;i<lengthII;i++) {
if (strII[i] == strI[now]) {
now ++ ;
cout << strII[i];
}
else {
now = j+1;
break;
}
}
cout << endl;
j++;
}
return 0;
}