Esempio n. 1
0
        static void Main(string[] args)
        {
            const int START_POSITION = 0;

            try
            {
                while (true)
                {
                    int[] arr = new[] { 50, 80, 35, 1382, 0, -20, 0, 98, 98 };
                    Console.WriteLine("Unsorted Array");
                    foreach (var i in arr)
                    {
                        Console.WriteLine(i);
                    }

                    Console.WriteLine("Select sort:");
                    Console.WriteLine("1-QuickSort");
                    Console.WriteLine("2-MergedSort");
                    int x = Convert.ToInt32(Console.ReadKey().KeyChar.ToString());
                    Console.WriteLine();
                    switch (x)
                    {
                    case 1:
                        Sorting.QuickSortMethod(arr, START_POSITION, arr.Length - 1);
                        break;

                    case 2:
                        arr = MergedSorting.Sort(arr);
                        break;
                    }

                    Console.WriteLine("Sorted Array");
                    foreach (var i in arr)
                    {
                        Console.WriteLine(i);
                    }


                    Console.WriteLine("++++++++++++++++++");
                }
            }

            catch (Exception e)
            {
                Console.WriteLine("================");
                Console.WriteLine(e.Message);
                Console.WriteLine("================");
            }
        }
 public void MergedSortTest()
 {
     arr = MergedSorting.Sort(arr);
     Assert.That(result, Is.EqualTo(arr));
 }