Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Vector:
- Способы задания:
- vector<int> a; // Пустой вектор
- vector<int> a(100); // [0, 0, ..., 0] x100
- vector<int> a(100, -3); // [-3, -3, ..., -3] x100
- vector<int> a = {1, 2, 3}; // [1, 2, 3] x100
- vector<int> a(3, 5); // [5, 5, 5]
- int b[3] = {-2, 4, 3};
- vector<int> a(b, b+3);
- Взаимодействие:
- a[0] = 2; //Нулевой элемент приравнять к 2
- v1 = v2; // Записать копию v1 в v2
- for(vector<int>::iterator it = v1.begin(); it != a.end(); it++)
- cout << *it;
- Методы:
- int size()
- bool empty()
- void push_back(int x) / push_front(int x)
- void insert(iterator pos, int x)
- void erase(iterator pos) / erase(iterator posStart, iterator posEnd)
- int front(), back() - Первый / Последний элемент
- void assign({int}) - Заменить значения вектора на значения массива
- void clear()
- List:
- Способы задания:
- list<int> b // Пустой список
- list<int> b(5) // [0, 0, 0, 0, 0]
- list<int> b(3, 5) // [5, 5, 5]
- list<int> b = {1, 2, 3} // [1, 2, 3]
- Взаимодействие:
- b1 = b2; // Записать копию v1 в v2
- for(list<int>::iterator it = v1.begin(); it != a.end(); it++)
- cout << *it;
- Методы:
- int size()
- bool empty()
- void push_back(int x) / push_front(int x)
- void insert(iterator pos, int x)
- void erase(iterator pos) / erase(iterator posStart, iterator posEnd)
- int front(), back() - Первый / Последний элемент
- void assign({int}) - Заменить значения списка на значения массива
- void clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement