摘要: View Code 1 //kmp算法2 #include"iostream"3 using namespace std;4 char s[10000001];5 int next[100001];6 int L;7 int i,j;8 void Index_kmp()9 {10 while(i<L) //kmp核心算法11 {12 if(j==0||s[i]==s[j]) //继续比较后继字符 13 { ++i; ++j; next[i]=j; }14 else15 j=next[j]; //串向右移动16 }17 }18 int main()19 {20 whil 阅读全文
posted @ 2011-03-15 20:26 聊聊IT那些事 阅读(297) 评论(0) 推荐(0) 编辑
摘要: 44 #include"iostream"45 #define M 1000 //适合数据量小的字符串,那么字符串长度过大时又如何处理?!46 using namespace std;47 int c[M][M];48 int Max(int a ,int b)49 {50 return a>b?a:b;51 }52 void LCD(char aa[], char bb[], int x, int y) //核心53 {54 int i,j;55 for(i=0;i<=x;i++)56 c[i][0]=0;57 for(j=0;j<=y;j++)58 c 阅读全文
posted @ 2011-03-15 19:38 聊聊IT那些事 阅读(1201) 评论(0) 推荐(0) 编辑