예제 #1
0
        public static void Main(string[] args)
        {
            SingleLinkedList <int> list1 = new SingleLinkedList <int>();

            for (int i = 0; i < 10; i++)
            {
                list1.Add(i + 1);
            }
            SingleLinkedList <int> list2 = new SingleLinkedList <int>(list1);

            list1.AddRange(list2);
            list1.Show();
            Console.WriteLine();
            list2.Show();
            Console.WriteLine();
            Console.WriteLine(Sum(list1));

            int[]  test = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            String s    = toString(test);

            Console.WriteLine(s);

            DoubleLinkedList <int> list3 = new DoubleLinkedList <int>();

            for (int i = 10; i < 20; i++)
            {
                list3.Add(i + 1);
            }
            list3.Remove(15);
            list3.Show();
            Console.WriteLine();
            Console.WriteLine(list3.IndexOf(12));
            DoubleLinkedList <int> list4 = new DoubleLinkedList <int>(list3);

            list4.Show();
            Console.WriteLine();

            int[] aa = { 10, 15, 20, 12, 13, 19 };
            for (int i = 0; i < aa.Length; i++)
            {
                for (int j = i; j < aa.Length; j++)
                {
                    if (aa[j] < aa[i])
                    {
                        int temp = aa[i];
                        aa[i] = aa[j];
                        aa[j] = temp;
                    }
                }
            }
            for (int i = 0; i < aa.Length; i++)
            {
                Console.Write(aa[i].ToString() + ' ');
            }
            Console.WriteLine();
            Console.WriteLine();

            DoubleLinkedList <int> list5 = new DoubleLinkedList <int>();

            list5.Add(10);
            list5.Add(20);
            list5.Add(15);
            list5.Add(11);
            list5.Add(30);
            list5.Show();
            Console.WriteLine();
            //InsertSort(list5, 14);
            Sort(list5);
            list5.Show();
            Console.WriteLine();

            //list5.Show();
            //Console.WriteLine();
        }