Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            int choice, x;

            QueueL ql = new QueueL();

            while (true)
            {
                Console.WriteLine("1. Push an element on the queue");
                Console.WriteLine("2. Pop an element from the queue");
                Console.WriteLine("3. Display the top elements");
                Console.WriteLine("4. Display all queue members");
                Console.WriteLine("5. Display size of the queue");
                Console.WriteLine("6. Quit");
                Console.Write("Enter your choice: ");
                choice = Convert.ToInt32(Console.ReadLine());

                if (choice == 6)
                {
                    break;
                }

                switch (choice)
                {
                case 1:
                    Console.Write("Enther the element to be pushed: ");
                    x = Convert.ToInt32(Console.ReadLine());
                    ql.Insert(x);
                    break;

                case 2:
                    x = ql.Delete();
                    Console.WriteLine("Popped element is " + x);
                    break;

                case 3:
                    Console.WriteLine("Element at the front is " + ql.Peek());
                    break;

                case 4:
                    ql.Display();
                    break;

                case 5:
                    Console.WriteLine("Size of stack " + ql.Size());
                    break;

                default:
                    Console.WriteLine("Wrong Choice");
                    break;
                }
            }
            Console.WriteLine("Exit");
        }
Ejemplo n.º 2
0
        static void Main(String[] args)
        {
            int    choice, x;
            QueueL queue = new QueueL();

            while (true)
            {
                Console.WriteLine("1. Insert an element in the queue");
                Console.WriteLine("2. Delete an element from the queue");
                Console.WriteLine("3.Display element at the front");
                Console.WriteLine("4.Display all elements from the queue");
                Console.WriteLine("5.Display size of the queue");
                Console.WriteLine("6.quit");
                Console.Write("enter your choice");
                choice = Convert.ToInt32(Console.ReadLine());
                if (choice == 6)
                {
                    break;
                }
                switch (choice)
                {
                case 1:
                    Console.Write("enter the element to be inserted");
                    x = Convert.ToInt32(Console.ReadLine());
                    queue.Insert(x);
                    break;

                case 2:
                    x = queue.Delete();
                    Console.WriteLine("Deleted element is " + x);
                    break;

                case 3:
                    Console.WriteLine("element at the front is " + queue.Peek());
                    break;

                case 4:
                    queue.Display();
                    break;

                case 5:
                    Console.WriteLine("Size of the queueu is" + queue.Size());
                    break;

                default:
                    Console.WriteLine("wrong choice");
                    break;
                }
                Console.WriteLine();
            }
        }