Example #1
0
        static unsafe void Main(string[] args)
        {
            quickSort q = new quickSort();

            int[] array;

            //array = { 99,11,88,22,77,33,66,44,55,02};
            //int size = array.Length;

            Console.Write("sizeOf Array: ");
            int size = Convert.ToInt32(Console.ReadLine());

            array = new int[size];
            Console.WriteLine("\nEnter: ");
            for (int i = 0; i < array.Length; i++)
            {
                Console.Write("\tElement no. " + (i + 1) + ": ");
                array[i] = Convert.ToInt32(Console.ReadLine());
            }

            fixed(int *ptr = array)
            {
                Console.WriteLine("Unsorted Array");
                for (int i = 0; i < array.Length; i++)
                {
                    Console.Write(*(ptr + i) + " ");
                }


                q.Sort(ptr, 0, size - 1);


                Console.WriteLine("\n\n\nSorted Array");
                for (int i = 0; i < array.Length; i++)
                {
                    Console.Write(*(ptr + i) + " ");
                }
            }
        }
            public static void Main()
            {
                quickSort q_Sort = new quickSort();

                int[] arr = { 4, 3, 1, 4, 6, 7, 5, 4, 3, 5, 6, 87, 8 };
                for (int j = 0; j < arr.Length; j++)
                {
                    Console.Write(arr[j] + " ");
                }
                Console.WriteLine();
                q_Sort.arr = arr;

                q_Sort.len = q_Sort.arr.Length;

                // Sort the array
                q_Sort.QuickSort();

                for (int j = 0; j < q_Sort.len; j++)
                {
                    Console.Write(q_Sort.arr[j] + " ");
                }
                Console.WriteLine();
            }
            public static void Main()
            {
                quickSort q_Sort = new quickSort();

                int[] arr = { 4, 3, 1, 4, 6, 7, 5, 4, 3, 5, 6, 87, 8 };
                for (int j = 0; j < arr.Length; j++)
                {
                    Console.Write(arr[j] + " ");
                }
                Console.WriteLine();
                q_Sort.arr = arr;

                q_Sort.len = q_Sort.arr.Length;

                // Sort the array
                q_Sort.QuickSort();

                for (int j = 0; j < q_Sort.len; j++)
                {
                    Console.Write(q_Sort.arr[j] + " ");
                }
                Console.WriteLine();
            }