コード例 #1
0
        private static void CombSortMethod()
        {
            Console.WriteLine("CombSort");
            Console.WriteLine("Tamaño: 10 Mil");
            Console.WriteLine("Orden: Aleatorio");
            CombSort.combSort(ReadFile(1, 3));
            Console.WriteLine("Tiempo transcurrido: " + CombSort.elapsed);

            Console.WriteLine("\nOrden: Ascendente");
            CombSort.combSort(ReadFile(1, 1));
            Console.WriteLine("Tiempo transcurrido: " + CombSort.elapsed);

            Console.WriteLine("\nOrden: Descendente");
            CombSort.combSort(ReadFile(1, 2));
            Console.WriteLine("Tiempo transcurrido: " + CombSort.elapsed);

            Console.WriteLine("\n");

            Console.WriteLine("CombSort");
            Console.WriteLine("Tamaño: 100 Mil");
            Console.WriteLine("Orden: Aleatorio");
            CombSort.combSort(ReadFile(2, 3));
            Console.WriteLine("Tiempo transcurrido: " + CombSort.elapsed);

            Console.WriteLine("\nOrden: Ascendente");
            CombSort.combSort(ReadFile(2, 1));
            Console.WriteLine("Tiempo transcurrido: " + CombSort.elapsed);

            Console.WriteLine("\nOrden: Descendente");
            CombSort.combSort(ReadFile(2, 2));
            Console.WriteLine("Tiempo transcurrido: " + CombSort.elapsed);

            Console.WriteLine("\n");

            Console.WriteLine("CombSort");
            Console.WriteLine("Tamaño: 1 Millón");
            Console.WriteLine("Orden: Aleatorio");
            CombSort.combSort(ReadFile(3, 3));
            Console.WriteLine("Tiempo transcurrido: " + CombSort.elapsed);

            Console.WriteLine("\nOrden: Ascendente");
            CombSort.combSort(ReadFile(3, 1));
            Console.WriteLine("Tiempo transcurrido: " + CombSort.elapsed);

            Console.WriteLine("\nOrden: Descendente");
            CombSort.combSort(ReadFile(3, 2));
            Console.WriteLine("Tiempo transcurrido: " + CombSort.elapsed);

            Console.WriteLine("\n");
        }
コード例 #2
0
        public static int[] ReadFile(int size, int order)
        {
            string path = "";

            switch (size)
            {
            case 1:
                array = new int[10000];
                path  = "./arreglo10Mil";
                break;

            case 2:
                array = new int[100000];
                path  = "./arregloCienMil";
                break;

            case 3:
                array = new int[1000000];
                path  = "./arregloMillon";
                break;
            }
            TextReader reader = new StreamReader(path);

            for (int i = 0; i < array.Length; i++)
            {
                array[i] = Convert.ToInt32(reader.ReadLine());
            }
            if (order == 1)
            {
                CombSort.combSort(array);
            }
            else if (order == 2)
            {
                CombSort.combSort(array);
                Array.Reverse(array);
            }
            return(array);
        }