📄 1845158_ac_0ms_832k.c
字号:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int maxn,i,j;
char s1[202];
char s2[202],stp[202];
char t[2];
char a[102][102][80];
while(scanf("%s %s\n",&s1,&s2)!=EOF)
{
maxn=0;
a[0][0][0]='\0';
for (i=1;i<=strlen(s1);i++)
{
t[0]=s1[i-1];
t[1]='\0';
stp[0]='\0';
strcpy(stp,a[i-1][0]);
strcpy(a[i][0],strcat(stp,t));
}
a[0][0][0]='\0';
for (i=1;i<=strlen(s2);i++)
{
t[0]=s2[i-1];
t[1]='\0';
stp[0]='\0';
strcpy(stp,a[0][i-1]);
strcpy(a[0][i],strcat(stp,t));
}
for (i=0;i<strlen(s1);i++)
{
for (j=0;j<strlen(s2);j++)
{
if (s1[i]==s2[j])
{
t[0]=s1[i];
t[1]='\0';
stp[0]='\0';
strcpy(stp,a[i][j]);
strcpy(a[i+1][j+1],strcat(stp,t));
}
else
if (strlen(a[i][j+1]) < strlen(a[i+1][j]))
{
t[0]=s1[i];
t[1]='\0';
stp[0]='\0';
strcpy(stp,a[i][j+1]);
strcpy(a[i+1][j+1],strcat(stp,t));
}
else
{
t[0]=s2[j];
t[1]='\0';
stp[0]='\0';
strcpy(stp,a[i+1][j]);
strcpy(a[i+1][j+1],strcat(stp,t));
}
}
}
printf("%s\n",a[strlen(s1)][strlen(s2)]);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -