Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include "func.h"
- using std::cin;
- using std::cout;
- using std::endl;
- int main() {
- int n, m;
- cin >> n >> m;
- MyVector vec;
- vec.Read(n);
- char cmd;
- while (m--) {
- cin >> cmd;
- if (cmd == '+') {
- int index, x;
- cin >> index >> x;
- if (index != 0) {
- vec.Insert(x, index - 1);
- } else {
- vec.PushBack(x);
- }
- } else if (cmd == '-') {
- int index;
- cin >> index;
- if (index != 0) {
- vec.Erase(index - 1);
- } else {
- vec.PopBack();
- }
- } else if (cmd == '?') {
- cin >> cmd;
- if (cmd == '+') {
- cout << vec.Sum();
- } else if (cmd == '/') {
- cout << std::setprecision(4) << std::fixed
- << vec.Mean();
- } else if (cmd == '<') {
- cout << vec.Min();
- } else if (cmd == '>') {
- cout << vec.Max();
- }
- cout << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment