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

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

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

    so true

    心懷未來,開創未來!
    隨筆 - 160, 文章 - 0, 評論 - 40, 引用 - 0
    數據加載中……

    LCS

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

    我的算法,本質上和上篇博客中提到的算法是一樣的:
    #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)  編輯  收藏


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


    網站導航:
     
    主站蜘蛛池模板: free哆啪啪免费永久| 日本一线a视频免费观看| 一本久久综合亚洲鲁鲁五月天| 亚洲人成电影院在线观看| 每天更新的免费av片在线观看 | 国产成人免费手机在线观看视频 | 亚洲精品字幕在线观看| caoporn成人免费公开| 黑人大战亚洲人精品一区| 一级做a毛片免费视频| 曰韩亚洲av人人夜夜澡人人爽| 亚欧洲精品在线视频免费观看| 亚洲性在线看高清h片| 成人免费观看男女羞羞视频| 国产亚洲人成网站在线观看| 中文字幕一区二区三区免费视频| 亚洲精品国精品久久99热一| 无码专区AAAAAA免费视频| 亚洲综合激情视频| 69成人免费视频无码专区| 亚洲AV永久无码精品网站在线观看 | 亚洲一级特黄大片在线观看| XXX2高清在线观看免费视频| 亚洲va无码va在线va天堂| 啦啦啦完整版免费视频在线观看| 亚洲AV无码一区二区三区在线| 日韩视频在线免费| 中文字幕在线观看免费| 亚洲一区中文字幕久久| 成人免费视频77777| 特级无码毛片免费视频| 亚洲精品视频在线观看免费| 亚洲中文字幕日本无线码| 国产99视频免费精品是看6| 两性色午夜视频免费播放| 亚洲妇女水蜜桃av网网站| 日本一道本高清免费| 最近免费mv在线观看动漫| 国产亚洲中文日本不卡二区| 中文字幕日韩亚洲| 无遮免费网站在线入口|