Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Quick Sort");

            var listOfArrs = new List <int[]>()
            {
                new int[] { 1, 2, 3 },
                new int[] { 3, 2, 1 },
                new int[] {},
                new int[] { 3, 1, -1, 0, 2, 5 },
                new int[] { 2, 2, 1, 1, 0, 0, 4, 4, 2, 2, 2 },
                new int[] { 0 },
                new int[] { 3, -2, -1, 0, 2, 4, 1 },
                new int[] { 1, 2, 3, 4, 5, 6, 7 },
                new int[] { 2, 2, 2, 2, 2, 2, 2 }
            };

            foreach (var arr in listOfArrs)
            {
                Console.Write("Quick Sort array: ");

                foreach (var item in Quick.Sort(arr))
                {
                    Console.Write(" " + item);
                }

                Console.WriteLine();
            }
        }
Exemplo n.º 2
0
        public static void Main()
        {
            var array = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Quick <int> .Sort(array);

            Console.WriteLine(string.Join(", ", array));
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            int[] array = new int[] { 13, 10, 11, 18, 17, 12, 15, 14, 19, 16 };
            int   h     = array.Length;

            Quick ob = new Quick();

            ob.Sort(array, 0, h - 1);

            Console.WriteLine(String.Join(",", array));
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine()
                          .Split()
                          .Select(int.Parse)
                          .ToArray();

            Quick.Sort(input, 0, input.Length - 1);

            Console.WriteLine(string.Join(" ", input));
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            if (input == String.Empty)
            {
                return;
            }

            int[] arr = input
                        .Split()
                        .Select(int.Parse)
                        .ToArray();

            Quick.Sort(arr);

            Console.WriteLine(String.Join(" ", arr));
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            Student[] students =
            {
                new Student("Ivo", 4.1),
                new Student("Ana", 4.9),
                new Student("Iva", 4.3),
                new Student("Bob", 4.5),
                new Student("Joe", 4.7),
                new Student("Tom", 4.4),
                new Student("Iko", 4.6),
            };

            DisplayArrayToConsole(students);

            Quick.Partition(students, 0, students.Length - 1, Student.CompareName);
            DisplayArrayToConsole(students);

            Quick.Sort(students, 0, students.Length - 1, Student.CompareName);
            DisplayArrayToConsole(students);

            Quick.Sort(students, 0, students.Length - 1, Student.CompareGrade);
            DisplayArrayToConsole(students);
        }