<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 閱讀(198) 評論(0)  編輯  收藏


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


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 国产亚洲福利精品一区| 免费国产在线观看| 亚洲一区二区中文| 久久久久久AV无码免费网站下载 | 久久久久久a亚洲欧洲aⅴ| 草久免费在线观看网站| 亚洲国产综合精品中文字幕 | 亚洲精品在线免费观看视频| 免费av片在线观看网站| 久久久亚洲欧洲日产国码农村| 光棍天堂免费手机观看在线观看| 亚洲色欲一区二区三区在线观看| 成在线人免费无码高潮喷水| 国产亚洲人成A在线V网站| 两性色午夜视频免费网| 久久久久亚洲AV成人无码| 99在线热视频只有精品免费| 亚洲国产成人资源在线软件 | 成人免费网站久久久| 久久精品亚洲福利| 欧洲人免费视频网站在线| 亚洲精品日韩中文字幕久久久| 99在线视频免费观看视频 | 在线看片免费人成视频播| 亚洲精品国产成人专区| 日韩版码免费福利视频| 亚洲AV永久无码精品一福利 | 免费看国产一级特黄aa大片| 成人久久久观看免费毛片| 亚洲视频在线视频| 夫妻免费无码V看片| eeuss免费天堂影院| 久久久无码精品亚洲日韩按摩| 无码中文在线二区免费| 免费无码午夜福利片69| 久久亚洲精品成人| 国产青草视频在线观看免费影院| 少妇性饥渴无码A区免费| 亚洲人成网站18禁止久久影院 | 边摸边吃奶边做爽免费视频99| 亚洲综合熟女久久久30p|