<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    so true

    心懷未來,開創(chuàng)未來!
    隨筆 - 160, 文章 - 0, 評論 - 40, 引用 - 0
    數(shù)據(jù)加載中……

    LCS

    http://blog.csdn.net/v_JULY_v/article/details/6110269

    我的算法,本質(zhì)上和上篇博客中提到的算法是一樣的:
    #include <iostream>
    #include <string>
    #include <fstream>
    #include <sstream>
    #include <stdint.h>
    #include <string.h>
    #include <pthread.h>
    #include <vector>
    #include <map>
    #include <set>

    using namespace std;

    int LCS(const char* X, const char* Y, char* R) {
        if (NULL == X || NULL == Y || NULL == R) {
            return 0;
        }

        int xlen = strlen(X);
        int ylen = strlen(Y);

        map<int, map<int, int> > D;
        for (int i = 0; i < xlen; ++i) {
            int max = 0;
            for (int j = 0; j < ylen; ++j) {
                max = std::max(X[i] == Y[j] ? 1 : 0, max);
                if (i > 0) {
                    max = std::max(D[i - 1][j], max);
                    if (j > 0) {
                        max = std::max(D[i - 1][j - 1] + (X[i] == Y[j] ? 1 : 0), max);
                    }
                }
                D[i][j] = max;
                printf("(%d,%d) = %d\n", i, j, max);
            }
        }

        return D[xlen - 1][ylen - 1];
    }

    int main(int argc, char* argv[]) {
        const char* X = argc > 1 ? argv[1] : "abacbda";
        const char* Y = argc > 2 ? argv[2] : "cbada";
        char R[1024];
        printf("X:%s\n", X);
        printf("Y:%s\n", Y);
        int ret = LCS(X, Y, R);
        printf("ret:%d\n", ret);
        return 0;
    }

    posted on 2015-02-20 15:37 so true 閱讀(190) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 999国内精品永久免费观看| 皇色在线免费视频| 亚洲成人免费网址| 亚洲A∨无码无在线观看| 国产高潮流白浆喷水免费A片 | 免费观看亚洲人成网站| 亚洲国产精品日韩av不卡在线| 亚洲性线免费观看视频成熟| 亚洲午夜免费视频| 亚洲视频在线免费播放| 亚洲国产精品yw在线观看| 亚洲第一网站免费视频| 亚洲一卡2卡3卡4卡乱码 在线 | 免费视频淫片aa毛片| 中文字幕亚洲精品无码| 日韩在线视频免费看| 看成年女人免费午夜视频| 亚洲人成无码网WWW| a级毛片黄免费a级毛片| 亚洲国产日韩一区高清在线| 亚洲一区免费视频| 亚洲日本一线产区和二线 | 免费成人激情视频| 亚洲中文无码亚洲人成影院| 四虎影视在线永久免费看黄| 国产精品午夜免费观看网站| 亚洲av之男人的天堂网站| 波多野结衣免费在线观看| 久久人午夜亚洲精品无码区| 相泽亚洲一区中文字幕| 99热在线精品免费播放6| 亚洲色精品VR一区区三区| 亚洲精品乱码久久久久久不卡| 人妻免费一区二区三区最新| 亚洲精品美女在线观看播放| 大陆一级毛片免费视频观看 | 亚洲欧洲久久久精品| 久久精品免费视频观看| 亚洲毛片基地4455ww| 亚洲视频在线一区二区| 5555在线播放免费播放|