All pastes #440268 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-04-14 22:32 UTC
rendered paste body
#include <iostream>
#include <string>
using namespace std;

int m = strlen(x);
int n = strlen(y);
int C[n][m];
char s1[255];
char s2[255];
 

long int LCSLength(char x[],char y[])
{
 for(int i=1;i<=n-1;i++)
 {
  for(int j=1;j<=m-1;j++)
   { 
    if(x[i]=y[j]){C[i][j]++;}
     else {
            C[i][j] = max (C[i][j-1], C[i-1][j]);
          } 
   } 
 }
return C[n][m];
}

 
int main()
{
 


 cout << "First string:";
 cin.getline(s1, 255);
 cout << "Second string:";
 cin.getline(s2, 255);

 cout << LCSLength(s1,s2);
 
 

 return 0;
}