Advertisement
Ilya_konstantinov

10D2

Dec 7th, 2023 (edited)
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | Source Code | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include "func_d.h"
  4.  
  5. using std::cin;
  6. using std::cout;
  7. using std::endl;
  8.  
  9. int main()
  10. {
  11.   int n, m;
  12.   cin >> n;
  13.   cin >> m;
  14.   MyVector vec;
  15.   read(vec, n);
  16.  
  17.   char cmd;
  18.   while (m--) {
  19.     cin >> cmd;
  20.     if (cmd == '+') {
  21.       int index, x;
  22.       cin >> index >> x;
  23.       if (index--) insert(vec, x, index);
  24.       else push_back(vec, x);
  25.     } else if (cmd == '-') {
  26.       int index;
  27.       cin >> index;
  28.       if (index--) erase(vec, index);
  29.       else pop_back(vec);
  30.     } else if (cmd == '?') {
  31.       cin >> cmd;
  32.       if (cmd == '+')
  33.         cout << sum(vec);
  34.       else if (cmd == '/') {
  35.         cout << std::setprecision(4) << std::fixed;
  36.         cout << mean(vec);
  37.       } else if (cmd == '<')
  38.         cout << min(vec);
  39.       else if (cmd == '>')
  40.         cout << max(vec);
  41.       else if (cmd == 'D')
  42.         print_size(vec);
  43.       cout << endl;
  44.     }
  45.   }
  46.   del(vec);
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement