就是增删改几种方法嘛
递推也不难想
有点参照最长公共上升子序列的感觉
#include<bits/stdc++.h>
using namespace std;
const int N = 1117;
int n, m, f[N][N];
char a[N], b[N];
int main()
{
cin >> n >> a + 1 >> m >> b + 1;
for(int i = 1; i <= m; i ++) f[0][i] = i;
for(int i = 1; i <= n; i ++) f[i][0] = i;
for(int i = 1; i <= n; i ++)
for(int j = 1; j <= m; j ++)
if(a[i] == b[j]) f[i][j] = min(f[i-1][j] + 1, min(f[i][j-1] + 1, f[i-1][j-1]));
else f[i][j] = min(f[i-1][j], min(f[i][j-1], f[i-1][j-1])) + 1;
cout << f[n][m];
}