public string[,] a_ = new string[15, 15];
        public string[,] b_ = new string[9, 9];
        public void draw_mat()
        {
            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    a_[i, j] = "0";
                }
            }

            a_[1, 2] = "1";
            a_[1, 3] = "1";
            a_[1, 4] = "1";
            a_[3, 5] = "1";
            a_[3, 6] = "1";

            a_[1, 0] = "a";
            a_[2, 0] = "b";
            a_[3, 0] = "c";
            a_[4, 0] = "d";
            a_[5, 0] = "e";
            a_[6, 0] = "f";


            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    b_[i, j] = "0";
                }
            }

            b_[1, 2] = "1";
            b_[1, 3] = "1";
            b_[1, 4] = "1";
            b_[3, 5] = "1";
            b_[3, 6] = "1";
            b_[4, 7] = "1";
            b_[4, 8] = "1";

            b_[1, 0] = "a";
            b_[2, 0] = "b";
            b_[3, 0] = "c";
            b_[4, 0] = "c";
            b_[5, 0] = "e";
            b_[6, 0] = "g";
            b_[7, 0] = "e";
            b_[8, 0] = "f";

        }

        public int stm_(int d_a, int pre_a, int d_b, int pre_b)
        {
            if (a_[d_a, 0] != b_[d_b, 0])
                return 0;
            else
            {
                int m = number_of_one(d_a, a_);
                int n = number_of_one(d_b, b_);

                //if (m == 0 || n == 0)
                //    return 1;

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

                for (int i = 0; i < m; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        MAT[i, j] = 0;
                    }
                }

                for (int i = 1; i <= m; i++)
                {
                    for (int j = 1; j <= n; j++)
                    {
                        MAT[i, j] = Math.Max(MAT[i - 1, j], Math.Max(MAT[i, j - 1], MAT[i - 1, j - 1] +
                            stm_(pre_a + i + 1, i, pre_b + j + 1, j)));
                    }
                }
                return MAT[m, n] + 1;
            }
        }

        public int number_of_one(int row_i, string[,] mat_)
        {
            int res = 0;
            int loop__ = int.Parse(Math.Sqrt(double.Parse(mat_.Length.ToString())).ToString());
            for (int i = 0; i < loop__; i++)
            {
                if (mat_[row_i, i] == "1")
                    res++;
            }

            return res;
        }
This article has been dead for over six months. Start a new discussion instead.