예제 #1
0
    static void Main()
    {
        var    ARRAY_LENGTH = 3000;
        Random random       = new Random();

        int[] arrInt1 = new int[ARRAY_LENGTH];
        int[] arrInt2 = new int[ARRAY_LENGTH];
        int[] arrInt3 = new int[ARRAY_LENGTH];

        double[] arrDouble1 = new double[ARRAY_LENGTH];
        double[] arrDouble2 = new double[ARRAY_LENGTH];
        double[] arrDouble3 = new double[ARRAY_LENGTH];

        string[] arrString1 = new string[ARRAY_LENGTH];
        string[] arrString2 = new string[ARRAY_LENGTH];
        string[] arrString3 = new string[ARRAY_LENGTH];

        for (int i = 0; i < ARRAY_LENGTH; i++)
        {
            arrInt1[i] = random.Next(0, 1000);
            arrInt2[i] = arrInt1[i];
            arrInt3[i] = arrInt2[i];

            arrDouble1[i] = arrInt1[i];
            arrDouble2[i] = arrInt1[i];
            arrDouble3[i] = arrInt1[i];

            arrString1[i]  = ((char)random.Next(65, 91)).ToString();
            arrString1[i] += ((char)random.Next(65, 91)).ToString();
            arrString1[i] += ((char)random.Next(65, 91)).ToString();
            arrString2[i]  = arrString1[i];
            arrString3[i]  = arrString1[i];
        }

        SelectionSort.RunSelectionSortIntPerformance(ARRAY_LENGTH, ref arrInt1);
        SelectionSort.RunSelectionSortDoublePerformance(ARRAY_LENGTH, ref arrDouble1);
        SelectionSort.RunSelectionSortStringPerformance(ARRAY_LENGTH, ref arrString1);

        QuickSort.RunQuickSortIntPerformance(arrInt2);
        QuickSort.RunQuickSortDoublePerformance(arrDouble2);
        QuickSort.RunQuickSortStringPerformance(arrString2);

        InsertionSort.RunInsertionSortIntPerformance(ref arrInt3);
        InsertionSort.RunInsertionSortDoublePerformance(ref arrDouble3);
        InsertionSort.RunInsertionSortStringPerformance(ref arrString3);
    }