예제 #1
0
        static void Main(string[] args)
        {
            var stack = new Stacks <int>();

            stack.Add(1);
            stack.Add(2);
            stack.Add(3);
            stack.Add(4);
            stack.Add(5);

            System.Console.WriteLine(String.Format("Stack size {0}", stack.Size()));
            System.Console.WriteLine(String.Format("IS Empty Stack {0}", stack.isEmpty()));

            while (!stack.isEmpty())
            {
                System.Console.WriteLine(stack.Pop());
            }
        }
예제 #2
0
        public static void Main(string[] args)
        {
            Stacks s1     = new Stacks(100);
            Random rnd    = new Random();
            int    theNum = rnd.Next(0, 99);
            string userAns;

            Console.WriteLine("What do you want to do");
            Console.WriteLine(" push or pop");
            userAns = Console.ReadLine();
            if (userAns == "pop")
            {
                Stacks.Pop(theNum);
            }
            if (userAns == "push")
            {
                Stacks.Push(theNum);
            }
        }