zoukankan      html  css  js  c++  java
  • 10405 Longest Common Subsequence

    描述:要命的题,回车也算字符,只要是字符就要算才行,绝不能用scanf读取字符串
    #include <cstdio>
    #include <cstring>
    #define N 1010
    char str[N],s[N];
    int num[N][N];
    int main()
    {
      //  freopen("a.txt","r",stdin);
        while(gets(str))
        {
            gets(s);
            memset(num,0,sizeof(num));
            int len=strlen(str),count=strlen(s);
            for(int i=len-1; i>=0; i--)
                for(int j=count-1; j>=0; j--)
                    if(str[i]==s[j]) num[i][j]=num[i+1][j+1]+1;
                    else num[i][j]=num[i+1][j]>num[i][j+1] ? num[i+1][j] : num[i][j+1];
            printf("%d\n",num[0][0]);
        }
        return 0;
    }


  • 相关阅读:
    7
    6
    5.1
    5
    C#类库帮助类
    Asp.net 数据库依赖那些事
    C#使用NLog记录日志
    JQuery常用操作实现方式
    常用Sql 标量值函数
    Sql语句查询XML
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/2999566.html
Copyright © 2011-2022 走看看