输出所有最长公共子序列.docVIP

  • 1
  • 0
  • 约1.43千字
  • 约 3页
  • 2020-11-17 发布于河北
  • 举报
#includeiostream #includecstdio using namespace std; #includememory.h string a,b; int m,n; int ab[100][100]; int c[100][100]; int len; void buildab() { for(int i=0; ia.length(); i++) for(int j=0; jb.length(); j++) { if(a[i] == b[j]) { ab[i+1][j+1] = 1; } else { ab[i+1][j+1] = 0; } } } void lcs() { for(int i=0; i= m; i++) c[i][0] = 0; for(int j=0; j= n; j++) c[0][j] = 0; for(int i=1; i = m; i ++) { for(int j=1; j = n; j ++) { if(ab[i][j] == 1) { c[i][j] = c[i-1][j-1] + 1; } else { c[i][j] = (c[i-1][j] = c[i][j-1])? c[i-1]

文档评论(0)

1亿VIP精品文档

相关文档