Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <iostream>
- using namespace std;
- int main()
- {
- vector<int> v1;
- v1.push_back(1); v1.push_back(2); v1.push_back(3);
- //for (auto i : v1)cout << i << std::endl;
- //for (auto it = v1.begin(); it < v1.end(); it++) cout << *it << std::endl;
- //for (auto it = v1.end() - 1; it >= v1.begin(); --it) cout << *it << std::endl;
- // Reverse operator
- //for (auto it = v1.rbegin(); it < v1.rend(); it++) cout << *it << std::endl;
- //for (vector<int>::reverse_iterator it = v1.rbegin(); it < v1.rend(); it++) cout << *it << std::endl;
- vector<int>::iterator it = v1.begin();
- //cout << *it << *(it + 2);
- int i, j;
- cout << "Input: "; cin >> i >> j;
- //cout << *(it + i - 1);
- vector<int> v2;
- for (auto it = v1.begin() + i - 1; it <= v1.begin() + j - 1; it++)
- {
- std::cout << *it << std::endl;
- v2.push_back(*it);
- }
- std::cout << std::endl;
- for (auto v : v2)
- std::cout << v;
- std::cout << std::endl;
- vector<int> v3;
- for (it = v1.begin(); it < v1.end() - 1; it++) v3.push_back(*it + *(it + 1));
- for (auto v : v3) std::cout << v << std::endl;
- std::cout << std::endl;
- v1.insert(v1.begin(), 5, 5);
- for (auto v : v1) std::cout << v << std::endl;
- std::cout << std::endl;
- v1.erase(v1.begin(), v1.end() - 1);
- for (auto v : v1) std::cout << v << ' ';
- system("pause");
- return 0;
- }
- // Реализовать проверку корректности (чтобы программа не вылетала)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement