public static void Main(string[] args)
        {
            double[] arr = new double[MAX];
            int      n   = 0;

            switch (read_from_file("insert_sort.txt", ref arr, ref n))
            {
            case READ_SUCCESS:
            {
                Console.WriteLine("Read success");
                for (int i = 0; i < arr.Length; i++)
                {
                    Console.Write(arr[i] + "\t");
                }
                break;
            }

            case ERR_FILE_PATH: Console.WriteLine("Error file path"); break;

            case ERR_SIZE_REQUEST: Console.WriteLine("Error size request"); break;

            case ERR_CANNOT_CONVERT_NUMBER: Console.WriteLine("Error cannot convert to number"); break;

            default: Console.WriteLine("default"); break;
            }

            InsertSort.InsertionSort(ref arr, ref n);
            Console.WriteLine("\n\n\nSort success!!!");
            for (int i = 0; i < arr.Length; i++)
            {
                Console.Write(arr[i] + "\t");
            }
            Console.ReadKey();
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            const int count = 100000;
            var       array = Enumerable.Range(1, count).Shuffle().ToArray();

            var sw = new Stopwatch();

            sw.Start();
            InsertSort.Start(array);
            sw.Stop();

            Console.WriteLine(sw.ElapsedMilliseconds + "ms");
            // 3614ms for 100000

            Console.WriteLine(array.IsAscSort());
        }
 static void Main(string[] args)
 {
     Output(InsertSort.StraightInsertionSort());
     Console.ReadKey();
 }