标签:namespace ace int cpp code printf print gets 最小
#include <bits/stdc++.h>
using namespace std;
char s1[2550],s2[2550];
int f[2002][2002];
int n,m;
int main()
{
gets(s1 + 1);
gets(s2 + 1);
int l1 = strlen(s1 + 1);
int l2 = strlen(s2 + 1);
for (int i = 1;i <= l2;i++) f[0][i] = i;
for (int i = 1;i <= l1;i++) f[i][0] = i;
for (int i = 1;i <= l1;i++)
for (int j = 1;j <= l2;j++)
if (s1[i] == s2[j]) f[i][j] = f[i - 1][j - 1];
else f[i][j] = min(min(f[i - 1][j] + 1,f[i][j - 1] + 1),f[i - 1][j - 1] + 1);
printf("%d\n",f[l1][l2]);
return 0;
}
标签:namespace ace int cpp code printf print gets 最小
原文地址:https://www.cnblogs.com/czy--blog/p/11741848.html