public static void Main(string[] args)
    {
        QueueUsingStack que = new QueueUsingStack();

        que.add(1);
        que.add(2);
        que.add(3);
        for (int i = 0; i < 3; i++)
        {
            Console.WriteLine(q.remove());
        }
    }
예제 #2
0
    public static void Main(string[] args)
    {
        QueueUsingStack que = new QueueUsingStack();

        que.add(1);
        que.add(11);
        que.add(111);
        Console.WriteLine(que.remove());
        que.add(2);
        que.add(21);
        que.add(211);
        Console.WriteLine(que.remove());
        Console.WriteLine(que.remove());
        Console.WriteLine(que.remove());
        Console.WriteLine(que.remove());
        Console.WriteLine(que.remove());
    }
예제 #3
0
        private static void QueueUsingStackExercise()
        {
            try
            {
                QueueUsingStack stack = new QueueUsingStack();
                stack.Enqueue(10);
                stack.Enqueue(20);
                stack.Enqueue(30);

                Console.WriteLine(stack.Dequeue());
                Console.WriteLine(stack.Dequeue());
                Console.WriteLine(stack.Dequeue());
                stack.Enqueue(40);
                Console.WriteLine(stack.Dequeue());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }