Advertisement
Ilya_konstantinov

19E

Mar 18th, 2024
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | Source Code | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using std::vector;
  5. using std::cin;
  6. using std::cout;
  7. using std::endl;
  8.  
  9. #include "stack.h"
  10.  
  11. int main() {
  12.   int q; cin >> q;
  13.   Stack st;
  14.   std::string cmd;
  15.   while(q--) {
  16.     cin >> cmd;
  17.     if (cmd == "pop") {
  18.       pop(st);
  19.     } else if (cmd == "push") {
  20.       int x; cin >> x;
  21.       push(st, x);
  22.     } else if (cmd == "max") {
  23.       cout << max(st) << endl;
  24.     } else if (cmd == "top") {
  25.       cout << top(st) << endl;
  26.     }
  27.   }
  28.   del(st);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement