计算机科学系数据结构C#实现的代码(2.2)

闲来无事,拿大学时候的数据结构书来看,发现书记结构的算法都没有实际的代码来实现,故用C#来把所有的算法实际代码写出来,可能跟书上的不一样,如效率不高,请指正。

int[] LA = new int[] {1,4,6,8,9 };
            int[] LB = new int[] { 235610 };
            string s = "";
            int JCopy = 0;
            for (int i = 0; i < LA.Length; i++)
            {
                for (int j = JCopy; j < LB.Length; j++)
                {
                    if (LA[i] <= LB[j])
                    {
                       //记录b数组的现在的位置,break一下,在去读取a数组
                        JCopy = j;
                        s += LA[i].ToString();
                        break;
                    }
                    else
                    {
                        //a比b大继续循环b数组
                        s += LB[j].ToString();
                    }
                }
            }
            Console.Write(s);
            Console.Read();
原文地址:https://www.cnblogs.com/theMaxBear/p/3674676.html