本文实例讲述了C++动态规划之最长公子序列解决方法。分享给大家供大家参考。具体分析如下:
问题描述:
求出两个字符串中的最长公子序列的长度。
输入:
csblog
belong
输出:
max length = 4
实现代码:
#include <stdio>
#include <string>
int arr[200][200];
/* 表示str1的前i位和str2的前j位的最长公子序列的长度 */
int main()
{
char str1[100],str2[100];
/* 输入数据 */
scanf(%s%s,str1,str2);
int len1 = s