• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            DraculaW

              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
              19 隨筆 :: 0 文章 :: 7 評論 :: 0 Trackbacks
            template<typename T>
            void prefix(T* p, int m, int* next)
            {
                   int i, j;
                   i = 0;
                   j = next[0] = -1;
                   while (i < m) {
                       while (j > -1 && p[i] != p[j])
                                 j = next[j];
                       i++;
                       j++;
                       if (p[i] == p[j])
                                 next[i] = next[j];
                       else
                                 next[i] = j;
                   }
            }
            /* ---------- end of function prefix ---------- */

            /*****************************************************************************
            * Function : KMP                                                            *
            * T     *t : The string need be matching                                    *
            * int    n : The length of the string                                       *
            * T     *p : The sub string to matching                                     *
            * int    m : The length of the p                                            *
            * int *out : An array mark the string match where ( max length is m - n )   *
            *****************************************************************************/
            template<typename T>
            int KMP(T* t, int n, T* p, int m, int* out)
            {
                      int c = 0;
                int i, j, next[m];
                prefix(p, m, next);
                i = 0;
                j = 0;
                while(i < n)
                {
                    while( j > -1 && p[j] != t[i])
                        j = next[j];
                    i++; j++;
                    if( j >= m )
                    {       
                        out[c++] = i - m;
                        j = next[j];
                    }
                }
                      return c;
            }
            /* ---------- end of function KMP ---------- */

            // 這個算法 也研究了很久了。對于他的原理 我早已經清楚,但是快速的寫出他還是不是那么順利。也是因為我寫的程序太少了吧 呵呵。 理解中記憶。 嗯 不能死記硬背啊 呵呵。
            posted on 2007-11-15 20:36 DraculaW 閱讀(91) 評論(0)  編輯 收藏 引用
            久久99精品久久久久子伦| 国产成人久久777777| 久久综合亚洲色HEZYO社区 | 伊人久久亚洲综合影院| 国产A级毛片久久久精品毛片| 一级做a爰片久久毛片16| 久久精品无码一区二区日韩AV | 久久综合九色综合网站| 青草国产精品久久久久久| 色综合合久久天天综合绕视看 | 国产精品永久久久久久久久久| 欧美久久亚洲精品| 久久丫精品国产亚洲av| 久久婷婷五月综合97色直播| 午夜精品久久久久久99热| 久久久久无码中| 日本精品久久久久中文字幕8| 久久婷婷五月综合国产尤物app| 高清免费久久午夜精品| 亚洲人成精品久久久久| 久久久久亚洲AV成人网| 狠狠狠色丁香婷婷综合久久俺| 欧美精品国产综合久久| 亚洲日本va午夜中文字幕久久| 日本精品久久久久中文字幕| 2021少妇久久久久久久久久| 亚洲精品无码久久久久去q | 久久99热狠狠色精品一区| 久久久噜噜噜久久中文字幕色伊伊 | 狠狠色丁香久久婷婷综| 日韩久久久久久中文人妻| 久久久久久久精品妇女99| 亚洲日本va午夜中文字幕久久| 久久国产精品免费| 日日狠狠久久偷偷色综合0| 久久婷婷五月综合色99啪ak| 久久久久久毛片免费看| 亚洲欧洲精品成人久久奇米网| 麻豆久久久9性大片| 久久婷婷五月综合成人D啪 | 乱亲女H秽乱长久久久|