Пример #1
0
        static void Main(string[] args)
        {
            int    n    = Convert.ToInt32(Console.ReadLine());
            Random rand = new Random();

            int[] arr = new int[n];
            for (int i = 0; i < arr.Length; i++)
            {
                arr[i] = rand.Next(0, 100);
            }

            Console.WriteLine("Original array : ");
            for (int i = 0; i < arr.Length; i++)
            {
                Console.Write(arr[i] + "\t");
            }
            Console.WriteLine();

            QuickSort1.QuickSort(arr, 0, arr.Length - 1);

            Console.WriteLine();
            Console.WriteLine("Sorted array : ");

            for (int i = 0; i < arr.Length; i++)
            {
                Console.Write(arr[i] + "\t");
            }
            Console.WriteLine("\n");
        }
Пример #2
0
        static void Main()
        {
            var random = new Random();

            var qSort = new QuickSort1();

            var arrays = new int[random.Next(1000)];

            for (var i = 0; i < arrays.Length - 1; i++)
            {
                arrays[i] = random.Next(random.Next(1000));
            }
            var sw = new Stopwatch();

            sw.Start();
            qSort.array = arrays;
            qSort.len   = qSort.array.Length;
            qSort.QuickSortAlgorithm();
            sw.Stop();
            Console.WriteLine("Time = " + sw.ElapsedMilliseconds + " ms");
            //for (int j = 0; j < qSort.len; j++)
            //{
            //    Console.WriteLine(qSort.array[j]);
            //}
            Console.ReadKey();
        }