0

I want to allow users to input their own characters to find the lowest common subsequence, this code is mostly a skeleton of somebody else's work- and the characters used are AGGTAB and GXTXYAB which is GTAB however I want users to implement their own characters

code for longest common subsequence:

class GFG
{
    public static void Main()
    {

        int m = X.Length;
        int n = Y.Length;
        Console.WriteLine("Write down characters for string A");
         string A = Console.ReadLine();
        Console.WriteLine("Write down characters for string B");
        string B = Console.ReadLine();

        int[,] L = new int[m + 1, n + 1];

        for (int i = 0; i <= m; i++)
        {
            for (int j = 0; j <= n; j++)
            {
                if (i == 0 || j == 0)
                    L[i, j] = 0;
                else if (X[i - 1] == Y[j - 1])
                    L[i, j] = L[i - 1, j - 1] + 1;
                else
                    L[i, j] = Math.Max(L[i - 1, j], L[i, j - 1]);
            }
        }
    }
}
Olivier Jacot-Descombes
  • 104,806
  • 13
  • 138
  • 188

0 Answers0