PersonalCorpus 版 (精华区)

1228410 Big Guava ... 10405 Accepted
0:00.301 5124 2002/11/11 02:08:13.552

void main()
{
#ifndef ONLINE_JUDGE
    freopen("k:\\iC","r",stdin);
    freopen("k:\\oC","w",stdout);
#endif

    int i,j,k,m,n,c[1100][1100];
    char s[1100],t[1100];
    
    while (gets(s)!=NULL) {
        gets(t);
        memset(c,0,sizeof(c));
        m=strlen(s);
        n=strlen(t);
        if ((m==0)||(n==0)) {
            printf("0\n");
            continue;
        }
        for (i=1;i<=m;i++) for (j=1;j<=n;j++)
            if (s[i-1]==t[j-1]) c[i][j]=c[i-1][j-1]+1;
            else if (c[i-1][j]>=c[i][j-1]) c[i][j]=c[i-1][j];
            else c[i][j]=c[i][j-1];
        printf("%d\n",c[m][n]);
    }
}
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.275毫秒