public static void Main()
        {
            var stack = new LinkedStack <int>();

            stack.Push(1);
            stack.Push(2);
            stack.Push(10);
            stack.Push(69);
            stack.Push(69);

            while (stack.Count > 0)
            {
                Console.WriteLine($"Pop: {stack.Pop()}");
            }

            stack.Push(1);
            stack.Push(2);
            stack.Push(10);
            stack.Push(69);
            stack.Push(69);

            var popped = stack.Pop();

            Console.WriteLine($"Popped element: {popped}");

            var arr = stack.ToArray();

            Console.WriteLine(
                "Stack to array representataion: {0}",
                string.Join(", ", arr));
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var stack = new LinkedStack <int>();

            stack.Push(10);
            stack.Push(15);
            stack.Push(20);
            stack.Push(25);

            var arr = stack.ToArray();

            foreach (var item in arr)
            {
                Console.WriteLine(item);
            }
        }
        public static void Main(string[] args)
        {
            var linkedStack = new LinkedStack <int>();

            linkedStack.Push(20);
            linkedStack.Push(2);
            linkedStack.Push(12);
            linkedStack.Push(5);
            var arr = linkedStack.ToArray();

            Console.WriteLine(string.Join(", ", arr));
            Console.WriteLine(linkedStack.Peek());
            linkedStack.Pop();
            var arr3 = linkedStack.ToArray();

            Console.WriteLine(string.Join(", ", arr3));
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            LinkedStack <int> newStack = new LinkedStack <int>();

            for (int i = 0; i < 100; i++)
            {
                newStack.Push(i);
            }

            int[] array = newStack.ToArray();

            foreach (var i in array)
            {
                Console.WriteLine(i);
            }

            Console.WriteLine("Stack pop");
            for (int i = 100; i >= 1; i--)
            {
                Console.WriteLine(newStack.Pop());
            }
        }