0001 #include <algorithm> 0002 using namespace std; 0003 0004 unsigned int lcsRecursion( char const * A, int n, char const * B, int m ) { 0005 if ( n < 1 || m < 1 ) //trivial cases 0006 return 0; 0007 if ( A[n-1] == B[m-1] ) //decrease & conquer 0008 return 1 + lcsRecursion( A, n-1, B, m-1 ); 0009 else //divide & conquer 0010 return max( lcsRecursion( A, n-1, B, m ), lcsRecursion( A, n, B, m-1 ) ); 0011 }