KMP算法学习

---恢复内容开始---

void get_next(String T ,int[] next){
      //求模式串中T的next函数值并将其存入next数组
      int i,j;
      i = 1;
      j = 0;
      next[1] = 0;
      while(i < T[0])
      if(j == 0 || T[i] == t[j] ){
             ++ i;
             ++ j;
             next[i] = j ;
        }
         else{
               j = next[j];
        }
 }  

posted on 2013-12-30 16:04  水济尘  阅读(95)  评论(0)    收藏  举报