Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 1.STL Using queue container
- #include <iostream>
- #include <queue>
- using namespace std;
- void showsg(queue <int> sg)
- {
- queue <int> ss = sg;
- while (!ss.empty())
- {
- cout << '\t' << ss.front();
- ss.pop();
- }
- cout << '\n';
- }
- int main()
- {
- queue <int> fquiz;
- fquiz.push(10);
- fquiz.push(20);
- fquiz.push(30);
- cout << "The queue fquiz is : ";
- showsg(fquiz);
- cout << "\nfquiz.size() : " << fquiz.size();
- cout << "\nfquiz.front() : " << fquiz.front();
- cout << "\nfquiz.back() : " << fquiz.back();
- cout << "\nfquiz.pop() : ";
- fquiz.pop();
- showsg(fquiz);
- return 0;
- }
- //2. 1.STL Using stack container
- #include <iostream>
- #include <stack>
- using namespace std;
- void newstack(stack <int> ss)
- {
- stack <int> sg = ss;
- while (!sg.empty())
- {
- cout << '\t' << sg.top();
- sg.pop();
- }
- cout << '\n';
- }
- int main ()
- {
- stack <int> newst;
- newst.push(55);
- newst.push(44);
- newst.push(33);
- newst.push(22);
- newst.push(11);
- cout << "The stack newst is : ";
- newstack(newst);
- cout << "\n newst.size() : " << newst.size();
- cout << "\n newst.top() : " << newst.top();
- cout << "\n newst.pop() : ";
- newst.pop();
- newstack(newst);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement