c 2b 2b stack and queue

Solutions on MaxInterview for c 2b 2b stack and queue by the best coders in the world

showing results for - "c 2b 2b stack and queue"
Soren
16 Jan 2017
1#include <iostream>
2#include <stack> 
3#include <queue>
4using namespace std;
5
6void printStack(stack<int> custstack)
7{
8    for(int i = 0; i < 3; i++)
9    {
10        int y = custstack.top();
11        cout << y << endl;
12        custstack.pop();
13    }
14}
15
16void printQueue(queue<int> custqueue)
17{
18    for(int i = 0; i < 3; i++)
19    {
20        int y = custqueue.front();
21        cout << y << endl;
22        custqueue.pop();
23    }
24}
25
26int main ()
27{
28    cout << "Stack:" << endl;
29    // this stack stacks three elements one by one and displays each element before its removal
30    stack<int> MY_STACK; // define stack and initialize to 3 elements
31    MY_STACK.push(69); // last element popped / displayed
32    MY_STACK.push(68); // second element popped / displayed
33    MY_STACK.push(67); // third popped/displayed
34    printStack(MY_STACK);
35
36    cout << endl << "Switching to queue" << endl;
37
38    queue<int> MY_QUEUE;
39    MY_QUEUE.push(69); // first out
40    MY_QUEUE.push(68); // second out 
41    MY_QUEUE.push(67); // third out
42    printQueue(MY_QUEUE);
43    return 0;
44}
queries leading to this page
queue c 2b 2b codestack and queue in c 2b 2bimplement a queue using two stacks stack using queue c 2b 2bc 2b 2b stack and queuestack and queue c 2b 2bstlstack c 2b 2b implementationqueue implementation in c 2b 2b using stackimplementation of stack using queue c 2b 2bstack using queue in cppc 2b 2b stacks and queue using arraystack and queue c 2b 2b examplestack and queue i c 2b 2bstack to queue c 2b 2bimplement stack using queue cppstack and queue in cppimplement queue using stack stlstack and queue using stlqueue and stack in c 2b 2bimplement a stack using queues c 2b 2bimplement queue using stack coding blocks c 2b 2bstack and queue implementation c 2b 2bstack and queue c 2b 2bstacks and queues c 2b 2b codec 2b 2b queue from stackstack 2c queue using c 2b 2btaking stack to queue c 2b 2bstack h in c 2b 2bqueue using stack in cppstack implementation in c 2b 2bimplement queue using stack c 2b 2bimplement stack using queue c 2b 2bimplementing queue using stack in c 2b 2bc 2b 2b stack and queue applicationc 2b 2b queue to stackimplement queue using stacks c 2b 2bstacks and queues in cppqueue using stacksdata from stack to queue c 2b 2bstack and queue c 2b 2b stlc 2b 2b stack queuestack implementation with deque cppstack and queue c 2b 2b completionwrite a c 2b 2b program to add data of stack1 to stack2 using stlstack vs queue c 2b 2bstack using queue in c 2b 2bdata structures queue and stack cycle c 2b 2bstack and queue stl c 2b 2bhow to create stack in c 2b 2bwrite a function to empty stack1 into the stack2 in the same relative order 2c if the process is failed 2c leave the stacks unchangedstack queue hard in c 2b 2bstack and queue implementation in c 2b 2bimplementation of stack and queue using array in c 2b 2bqueue code c 2b 2bwhat will happen if we try to pop items from empty queuec 2b 2b queue of stacksa stack that uses a number of queues c 2b 2bin a stack the command to access nth element from the top of the stack will be 2a 1 point s 5btop 1 5d s 5btop 2b1 5d s 5btop n 1 5d none of the abovestacks queue in c 2b 2bstacks and queues for cppstack queue c 2b 2bcreate a queue using stacks c 2b 2bstack queue in c 2b 2bstl stack and queuec 2b 2b stack and queue