#include
using namespace std;
void Get_Next(char* T,int* next);
void Get_Nextval(char* T,int* next);
int Index_KMP(char* S,char* T,int* N);
int main()
{
char S[500];
char T[255];
int N[255];
cout<
cin>>S;
cout<
cin>>T;
Get_Next(T,N);
//
Get_Nextval(T,N);
for(int i=0;i
{
cout<
}
cout<
//cout<
return 0;
}
int Index_KMP(char* S,char* T,int* N)
{
int i,j;
i=0;
j=0;
int sl = strlen(S);
int tl = strlen(T);
while(i
<%}%>
{
if(j == -1 ||S[i] == T[j])
{
i++;
j++;
}
else
{
j = N[j];
}
}
if(j==strlen(T))
{
return i-j;
}
else
{
return -1;
}
}
void Get_Next(char* T,int* next)
{
int i,j;
i=0;
j=-1;
next[0]=-1;
while(i
{
if(j==-1 || T[i] == T[j])
{
i++;
j++;
next[i] = j;
}
else
{
j = next[j];
}
}
}
void Get_Nextval(char* T,int* next)
{
int i,j;
i=0;
j=-1;
next[0]=-1;
while(i
{
if(j==-1 || T[i] == T[j])
{
i++;
j++;
if (T[i] != T[j])
next[i] = j;
else
next[i] = next[j];
}
else
{
j = next[j];
}
}
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25361369/viewspace-720121/,如需转载,请注明出处,否则将追究法律责任。
请登录后发表评论
登录
全部评论
<%=items[i].createtime%>
<%=items[i].content%>
<%if(items[i].items.items.length) { %>
<%for(var j=0;j
<%}%> <%if(items[i].items.total > 5) { %>
<%}%>
<%=items[i].items.items[j].createtime%>
<%=items[i].items.items[j].username%> 回复 <%=items[i].items.items[j].tousername%>: <%=items[i].items.items[j].content%>
还有<%=items[i].items.total-5%>条评论
) data-count=1 data-flag=true>点击查看
<%}%>
转载于:http://blog.itpub.net/25361369/viewspace-720121/