Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //6.a)
            Console.WriteLine("6.a)________________________________");
            int[] inputA = new int[] { 3, 7, 4, 2, 8, 5, 7, 1, 6, 9, 7, 0 };
            Quicksort(inputA);
            Console.WriteLine(string.Join(", ", inputA));

            //6.b)
            Console.WriteLine("6.b)________________________________");
            int[] inputB = new int[] { 3, 7, 4, 2, 8, 5, 7, 1, 6, 9, 7, 0 };
            UnluckySort(inputB, 7);
            Console.WriteLine(string.Join(", ", inputB));
            UnluckySort(inputB, 8);
            Console.WriteLine(string.Join(", ", inputB));

            //7.a)
            Console.WriteLine("7.a)________________________________");
            MyStack <int> stack = new MyStack <int>();

            Console.WriteLine($"Count: {stack.Count()}");
            stack.Push(1);
            stack.Push(2);
            Console.WriteLine($"Peek: {stack.Peek()}");
            stack.Push(3);
            Console.WriteLine($"Count: {stack.Count()}");
            Console.WriteLine($"{stack.Pop()}, {stack.Pop()}, {stack.Pop()}");

            //7.b)
            Console.WriteLine("7.b)________________________________");
            StackedQueue <string> queue = new StackedQueue <string>();

            Console.WriteLine($"Count: {queue.Count()}");
            queue.Enqueue("Uno");
            queue.Enqueue("Dos");
            Console.WriteLine(queue.Dequeue());
            queue.Enqueue("Tres");
            queue.Enqueue("Cuatro");
            Console.WriteLine(queue.Dequeue());
            queue.Enqueue("Cinco");
            queue.Enqueue("Seis");
            Console.WriteLine($"Peek: {queue.Peek()}");
            Console.WriteLine(queue.Dequeue());
            Console.WriteLine($"Count: {queue.Count()}");

            //Bonus
            StackedQueue <char> bonusQueue = new StackedQueue <char>();

            bonusQueue.Enqueue('b');
            bonusQueue.Enqueue('a');
            bonusQueue.Enqueue('d');
            bonusQueue.Enqueue('c');

            bonusQueue.Sort();
            string bonusOutput = "";

            while (bonusQueue.Count() > 0)
            {
                bonusOutput += bonusQueue.Dequeue();
            }
            Console.WriteLine(bonusOutput);
        }