>
Queue: A queue is a container of objects that are inserted and removed according to first-in-first-out(FIFO) principle. [Problem] Enq...
Queue: A queue is a container of objects that are inserted and removed according to first-in-first-out(FIFO) principle.
[Problem]
Enqueue the given N (2 <=N <=100) numbers in order into a queue, then dequeue each and print on the screen.
[Input]
The first input line contains the number of test cases,T.
The next line contains the number of data input.
Then,integer data will be listed.
[Output]
For each given test case,print each queue.
Input OUTPUT
2 //Test case #1 1 2 3 4 5
5 //Data size #2 5 4 3 2 1
1 2 3 4 5
5
5 4 3 2 1
>
Stack: A stack is a container of objects that are inserted(push) and removed (pop) according to the last-in-first-out(LIFO) principle. ...
Stack: A stack is a container of objects that are inserted(push) and removed (pop) according to the last-in-first-out(LIFO) principle.
[Problem]
Insert(Push) the given N (2 <=N <=100) numbers in order into a stack, then pop each and print on the screen.
[Input]
The first input line contains the number of test cases,T.
The next line contains the number of data input.
Then,integer data will be listed.
[Output]
For each given test case,print each stack.
Input OUTPUT
2 //Test case #1 5 4 3 2 1
5 //Data size #2 1 2 3 4 5
1 2 3 4 5
5
5 4 3 2 1