Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <queue> /// fifo
- #include <vector> /// fifo
- #include <stack>
- using namespace std;
- vector<int> v;
- queue<int> q;
- stack<int> s;
- int main()
- {
- /// also check this: https://en.cppreference.com/w/cpp/container/vector
- v.push_back(1);
- v.push_back(2);
- v.push_back(3);
- for(int i=0; i<v.size(); i++)
- {
- cout << v[i] << ' '; /// O[1]
- }
- cout << endl;
- q.push(1);
- q.push(2);
- q.push(3);
- int k = q.size();
- for(int i=0; i<k; i++)
- {
- cout << q.front() << ' ';
- q.pop();
- }
- cout << endl;
- s.push(1);
- s.push(2);
- s.push(3);
- k = s.size();
- for(int i=0; i<k; i++)
- {
- cout << s.top() << ' ';
- s.pop();
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment