路过。看了第三题没做,这样是否可行: #include<iostream> using namespace std; int main() {     string s1 = " ";     string s2 = " ";     string mid;     cin >> mid;     s1 += mid;     cin >> mid;     s2 += mid;     int len1 = s1.length();     int len2 = s2.length();     int dp[11][11] = {};     for (int i = 1; i < len2; i++) {         for (int j = i; j < len1; j++) {             if (s2[i] == s1[j]) {                 dp[i][j] = dp[i - 1][j - 1] + 1;             } else {                 dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);             }cout << dp[i][j] << " ";         }cout << endl;     }     cout << len2 - 1 - dp[len2 - 1][len1 - 1] << endl; }</iostream>
点赞

相关推荐

牛客网
牛客企业服务