コード例 #1
0
ファイル: Program.cs プロジェクト: aykuttasil/data-structure
        static void Main(string[] args)
        {
            StackDataStructure stackData = new StackDataStructure();

            stackData.push(1);
            stackData.push(2);
            stackData.push(3);

            stackData.printList();

            stackData.push(4);
            stackData.push(5);
            stackData.push(6);
            stackData.push(7);
            stackData.pop();
            stackData.push(8);

            stackData.printList();

            stackData.printList();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to a stack implementation example");
            Console.WriteLine("Generating a sample stack...");
            IStack stack = new StackDataStructure();

            Console.WriteLine($"Stack IsEmpty? {stack.IsEmpty()}");

            for (int i = 0; i < 10; i++)
            {
                stack.Push(i + 1);
                Console.WriteLine($"Pushed {stack.Top} on the stack");
            }

            Console.WriteLine($"Peek at the top of the stack: {stack.Peek()}");
            Console.WriteLine("Pop until the stack is empty...");

            while (!stack.IsEmpty())
            {
                Console.WriteLine(stack.Pop());
            }
        }