Advertisement
Ilya_konstantinov

10C1

Dec 7th, 2023 (edited)
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | Source Code | 0 0
  1. #include <iostream>
  2. #include "func_c.h"
  3.  
  4. using std::cin;
  5. using std::cout;
  6. using std::endl;
  7.  
  8. int main() {
  9.   int n, q, x, k; cin >> n;
  10.   char cmd;
  11.   MyVector vec;
  12.   read(vec, n);
  13.   cin >> q;
  14.   while (q--) {
  15.     cin >> cmd;
  16.     if (cmd == '+') {
  17.       cin >> k >> x;
  18.       if (k--) insert(vec, x, k);
  19.       else push_back(vec, x);
  20.     } else if (cmd == '-') {
  21.       cin >> k;
  22.       if (k--) erase(vec, k);
  23.       else pop_back(vec);
  24.     } else if (cmd == '?') {
  25.         print_size(vec);
  26.         cout << '\n';
  27.     }    
  28.   }
  29.   print(vec);
  30.   del(vec);
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement