include<iostream>
include<string>
using namespace std;
int main(){
cout<<"请输入两个字符串"<<endl;
string str1;
string str2;
cin>>str1>>str2;
int len1 = str1.length();
int len2 = str2.length();
//i,j公共子序列长度
int c [len1+1][len2+1];
for(int i = 0; i <= len1; i++)
for(int j = 0; j <= len2; j++){
if( i==0 || j==0){
c[i][j] = 0;
}else if( str1[i-1] == str2[j-1] ){
c[i][j] = c[i-1][j-1] + 1;
}else{
c[i][j] = max(c[i-1][j], c[i][j-1]);
}
}
cout<<"最大公共子序列长度为:"<<c[len1][len2]<<endl;
}