mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
improved the code
This commit is contained in:
parent
cc9e8d0d17
commit
d3185357bd
@ -25,10 +25,22 @@ void Print(int trace[20][20], int m, int n, string a)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int lcs(string a, string b){
|
int lcs(string a, string b)
|
||||||
|
{
|
||||||
int m = a.length(), n = b.length();
|
int m = a.length(), n = b.length();
|
||||||
int res[m+1][n+1];
|
int res[m+1][n+1];
|
||||||
int trace[20][20];
|
int trace[20][20];
|
||||||
|
|
||||||
|
// fills up the arrays with zeros.
|
||||||
|
for (int i = 0; i < m+1; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < n+1; j++)
|
||||||
|
{
|
||||||
|
res[i][j] = 0;
|
||||||
|
trace[i][j] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < m+1; ++i)
|
for (int i = 0; i < m+1; ++i)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < n+1; ++j)
|
for (int j = 0; j < n+1; ++j)
|
||||||
|
Loading…
Reference in New Issue
Block a user