Ejemplo n.º 1
0
        public void MergeortResultsinSuccess()
        {
            int[] input          = new int[] { 54, 26, 93, 17, 77, 31, 44, 55, 20 };
            int[] expectedResult = new int[] { 17, 20, 26, 31, 44, 54, 55, 77, 93 };

            MergeSortSolution.MergeSort(input);

            Assert.Equal(input, expectedResult);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            int[] array = new int[] { 5, 2, 6, 4, 7, 10, 1, 9, 3, 8 };

            array = MergeSortSolution.MergeSort(array);

            // Print the sorted list
            for (int index = 0; index < array.Length; index++)
            {
                Console.WriteLine("element[{0}] = {1}", index, array[index]);
            }

            Console.WriteLine();
            Console.ReadLine();
        }
    public static void Main()
    {
        int n = Convert.ToInt32(Console.ReadLine());

        int[] array = Console
                      .ReadLine()
                      .Split()
                      .Select(int.Parse)
                      .ToArray();

        Console.WriteLine(String.Join(" ", array));

        var solution = new MergeSortSolution();

        int[] sorted = solution.MergeSort(array);

        Console.WriteLine(String.Join(" ", sorted));
        Console.WriteLine(solution.Count);
    }