Write a program that creates a Queue from a stack. After creation the top of the stack will be the front of the queue.
Input Data-
S: 1 2 3 4 5
Output Data-
Q: 5 4 3 2 1
Given an integer k and a queue of integers, write a program to remove the first k elements of the queue, reverse their order and append them at the end of the queue, leaving the other elements in the same relative order.
Only a stack can be used as an auxiliary space and the following standard operations are allowed on queue.
• enqueue(x) : Add an item x to rear of queue
• dequeue() : Remove an item from front of queue
Examples:
Input: Q = 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, k =5
Output: Q = 60, 70, 80, 90, 100, 50, 40, 30, 20, 10
Input: Q = 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, k =2
Output: Q = 30, 40, 50, 60, 70, 80, 90, 100, 20, 10