Last active
May 28, 2017 03:39
-
-
Save vik-y/8ddea4dcb44d3395d8c63f859c32a20d to your computer and use it in GitHub Desktop.
Simple Examples of stack and queue in C++ Standard Library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cplusplus reference can be useful | |
// http://www.cplusplus.com/reference/queue/queue/ | |
#include <iostream> | |
#include <queue> | |
#include <stack> | |
int main(){ | |
std::stack<int> s; // Define a stack which stores integers | |
std::queue<int> q; // Define a queue which stores integers | |
s.push(5); //Add an element to stack | |
q.push(5); //Add an element to queue | |
s.top(); // Get the element at the top of the the stack | |
q.front(); // Get the element at front of the queue | |
s.pop(); // Delete the top element in stack | |
q.pop(); // Delete the element in front of the queue | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment