Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using std::vector;
- using std::cin;
- using std::cout;
- using std::endl;
- #include "stack.h"
- int main() {
- int q; cin >> q;
- Stack st;
- std::string cmd;
- while(q--) {
- cin >> cmd;
- if (cmd == "pop") {
- pop(st);
- } else if (cmd == "push") {
- int x; cin >> x;
- push(st, x);
- } else if (cmd == "max") {
- cout << max(st) << endl;
- } else if (cmd == "top") {
- cout << top(st) << endl;
- }
- }
- del(st);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement