编程实现动态规划的算法实验报告(12)
时间:2025-07-11
时间:2025-07-11
这是一份实验报告,内容是矩阵连乘问题和最长公共子序列问题
input = "S" + input;
y = input.toCharArray();
int[][] b = newint[x.length][y.length];
int[][] c = New int[x.length][y.length];
lcsLength(x, y, c, b);
// 计算最优值
lcs(x.length- 1, y.length
- 1, x, b);
// 构造最长公共子系列
int
size = resultList.size();
System.out.print("最长公共子系列为:"); for(
int
i = 0; i < size; i++) {
System.out.print(resultList.get(i));
}
System.out.println("\n");
}
catch
(IOException e) {
e.printStackTrace();
}
System.
out.print("继续输入请按y。。退出请按任意键!");
a=scan.nextLine();
}
while
(a.equals("y"));
}
}
连乘问题
上一篇:阿坝师专评优统计(三好等)
下一篇:“治百病”锻炼方法之10:拉筋