Пример #1
0
        private static void Method4()
        {
            MaxStack stack = new MaxStack();

            stack.Push(5);
            stack.PeekMax();
            stack.Pop();
        }
Пример #2
0
        private static void Method2()
        {
            MaxStack stack = new MaxStack();

            stack.Push(5);
            stack.Push(1);

            stack.PopMax();  //-> 5
            stack.PeekMax(); //-> 1
        }
Пример #3
0
        private static void Method3()
        {
            MaxStack stack = new MaxStack();

            stack.Push(74);
            stack.PopMax();
            stack.Push(89);
            stack.Push(67);
            stack.PopMax();
            stack.Pop();
            stack.Push(61);
            stack.Push(-77);
            stack.PeekMax();
            stack.PopMax();
        }
Пример #4
0
        static void Main(string[] args)
        {
            int range = 100;
            int tries = 10;
            var stack = new MaxStack();
            var rnd   = new Random();

            for (int i = 0; i < tries; i++)
            {
                int j = rnd.Next(range);
                stack.Push(j);
                Console.Write($"push: {j} max: {stack.Max()}\n");
            }
            Console.WriteLine();

            while (stack.Size() > 0)
            {
                Console.Write($"max: {stack.Max()} pop: {stack.Pop()}\n");
            }
            Console.WriteLine();
            Console.ReadKey();
        }