https://blog.csdn.net/ggdhs/article/details/90713154
#include <iostream> using namespace std; int main() { char str1[] = "helloworld"; char str2[] = "loop"; int arr[11][5] = {0}; for(uint32_t i=1; i<11;i++) { cout << str1[i-1] << endl; for(uint32_t j=1; j<5;j++) { cout<< str2[j-1]; if (str1[i-1] == str2[j-1]) { arr[i][j] = arr[i-1][j-1] + 1; } else {
// 公共子序列 arr[i][j] = max(arr[i-1][j], arr[i][j-1]); // 公共字串
// arr[i][j] = 0; } } cout << endl; } for(uint32_t i=0; i<11;i++) { for(uint32_t j=0; j<5;j++) { cout<<arr[i][j]; } cout<<endl; } return 0; }