91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2KB
    文件類型: .cpp
    金幣: 1
    下載: 0 次
    發布日期: 2021-06-13
  • 語言: C/C++
  • 標簽:

資源簡介

該算法程序可以計算兩個字符串包含的多個子序列和其長度,并同時輸出多個子序列

資源截圖

代碼片段和文件信息

#include
#include
#include
//#include
#include
using?namespace?std;
void?Print(int?iint?j);
string?str1str2;
int?t=0;//t表示分路數
int?L[100][100]={-1-1};int?M[100][100]={-1-1};
int?main()
{

//char?a[100]={-1};
cout<<“請輸入序列1“< cin>>str1;
cout<<“請輸入序列2“< cin>>str2;
int?n=str1.length();int?m=str2.length();int?s=0;
//vector?L;
//L.resize(n*m);

for(int?i=0;i {?L[i][0]=0;M[i][0]=0;}
for(int?j=0;j {??L[0][j]=0;M[0][j]=0;}
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
if(str1.at(i-1)==str2.at(j-1))
{
L[i][j]=L[i-1][j-1]+1;
????????????????????M[i][j]=1;//表示L[i][j]的值來自于斜對角線
}
else
{
if(L[i][j-1]>L[i-1][j])
{
L[i][j]=L[i][j-1];
????M[i][j]=2;//表示L[i][j]的值來自于左邊
}
else?if(L[i][j-1] {
L[i][j]=L[i-1][j];
???? M[i][j]=3;//表示L[i][j]的值來自于上

評論

共有 條評論

相關資源