Question: Queue in Standard Template Library (STL) . Queues are a type of container adaptors which operate in a first in first out (FIFO) type of
Queue in Standard Template Library (STL) .
Queues are a type of container adaptors which operate in a first in first out (FIFO) type of arrangement. Elements are inserted at the back (end) and are deleted from the front.
The functions supported by queue are :
empty() Returns whether the queue is empty
size() Returns the size of the queue
front() Returns a reference to the first element of the queue
back() Returns a reference to the last element of the queue
push(g) Adds the element g at the end of the queue
pop() Deletes the first element of the queue
Try to understand the code on the left, and modify the code to do the following tasks.
Exercise:
1. Input code to ask user "Please input a whole number n:"
2. Then after a user inputs a number n, generate n random numbers into a queue, and show the queue.
3. Use a stack to reverse the order the original queue, and also input them to the end of the queue, and show the queue.
Example:
If you have a 4 random number queue: 2 5 7 4
The final queue will be 2 5 7 4 4 7 5 2 Code:
#include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
