c++求两个字符串的最长公共子序列and子串
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}; // [0][0] default // [1,10], [1,4] 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; }