Ejemplo n.º 1
0
    static void Main(string[] args)
    {
        int[] OriginalArray = { 5, 89, 43, 13, 67, 11, 45 };
        int[] A = new int[OriginalArray.Length];
        SortingAlgorithms sortAlgo = new SortingAlgorithms();

        // insertion sort demo
        Array.Copy(OriginalArray, A, A.Length);
        sortAlgo.InsertionSort(A);
        Console.WriteLine("After insertion sort list contains: ");
        foreach (var item in A)
            Console.Write(" {0}", item);
        Console.WriteLine();

        // Selection sort demo
        Array.Copy(OriginalArray, A, A.Length);
        sortAlgo.SelectionSort(A);
        Console.WriteLine("After Selection sort list contains: ");
        foreach (var item in A)
            Console.Write(" {0}", item);
        Console.WriteLine();

        // Bubble sort demo
        Array.Copy(OriginalArray, A, A.Length);
        sortAlgo.BubbleSort(A);
        Console.WriteLine("After Bubble sort list contains: ");
        foreach (var item in A)
            Console.Write(" {0}", item);
        Console.WriteLine();
    }