Exemple #1
0
        static void Main(string[] args)
        {
            int choice, x;

            QueueA queue = new QueueA();

            while (true)
            {
                Console.WriteLine("1. Insert element to queue");
                Console.WriteLine("2. Remove an element from the queue");
                Console.WriteLine("3. Display the front element");
                Console.WriteLine("4. Display all queue elements");
                Console.WriteLine("5. Display the size of the queue");
                Console.WriteLine("6. Quit");

                Console.WriteLine("Enter your choice: ");
                choice = Convert.ToInt32(Console.ReadLine());

                if (choice == 6)
                {
                    break;
                }

                switch (choice)
                {
                case 1:
                    Console.WriteLine("Enter element to insert: ");
                    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 front is: " + queue.Peek());
                    break;

                case 4:
                    queue.Display();
                    break;

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

                default:
                    Console.WriteLine("Choice not in list");
                    break;
                }
                Console.WriteLine("");
            }
        }
Exemple #2
0
        static void Main(String[] args)
        {
            int choice, x;

            QueueA quA = new QueueA(8);

            while (true)
            {
                Console.WriteLine("1.Insert an element in Queue");
                Console.WriteLine("2.Delete an element from Queue");
                Console.WriteLine("3.Display front element");
                Console.WriteLine("4.Display all elements of Queue");
                Console.WriteLine("5.Display Size of Queue");
                Console.WriteLine("6.Quit");
                Console.WriteLine("Enter your choice:");
                choice = Convert.ToInt32(Console.ReadLine());

                if (choice == 6)
                {
                    break;
                }

                switch (choice)
                {
                case 1:
                    Console.WriteLine("Enter the element to be inserted:");
                    x = Convert.ToInt32(Console.ReadLine());
                    quA.Insert(x);
                    break;

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

                case 3:
                    Console.WriteLine("Front Element is: " + quA.Peek());
                    break;

                case 4:
                    quA.Display();
                    break;

                case 5:
                    Console.WriteLine("Size of Queue is: " + quA.Size());
                    break;

                default:
                    Console.WriteLine("Wrong choice:");
                    break;
                }
                Console.WriteLine("");
            }
        }
        static void Main(string[] args)
        {
            int    choice, x;
            QueueA qu = new QueueA(8);

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

                case 2:
                    x = qu.Delete();
                    Console.WriteLine("Element deleted is:" + x);
                    break;

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

                case 4:
                    qu.Display();
                    break;

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

                default:
                    Console.WriteLine("Wrong choice");
                    break;
                }
                Console.WriteLine(" ");
            }
        }
Exemple #4
0
        static void Main(String[] args)
        {
            int    choice, x;
            QueueA queue = new QueueA(10);

            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();
            }
        }