解题思路:
注意事项:
参考代码:
#include<bits/stdc++.h> using namespace std; string s1; string s2; int L1,L2; int dp[202][202]; int DP_(){ //fill(dp[0],dp[0]+202*202,1); for(int i=1;i<=L1;i++){ for(int j=1;j<=L2;j++){ if(s1[i-1]==s2[j-1]){ dp[i][j]=dp[i-1][j-1]; continue; } dp[i][j]=min(dp[i-1][j],dp[i][j-1])+1; } } /*for(int i=0;i<=L1;i++){ for(int j=0;j<=L2;j++){ cout<<dp[i][j]<<" "; } cout<<endl; }*/ return dp[L1][L2]; } main(){ cin>>s1>>s2; L1=s1.length(); L2=s2.length(); int ans=DP_(); cout<<ans; }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题11.5 (C语言代码)浏览:1514 |
【绝对值排序】 (C语言代码)浏览:713 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:540 |
【偶数求和】 (C语言代码)浏览:556 |
【金明的预算方案】 (C++代码)浏览:937 |
C语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:562 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:533 |
关于C语言变量位置的问题浏览:272 |
回文数字 (C语言代码)浏览:2509 |
GC的苦恼 (C语言代码)浏览:618 |