SHOW:
|
|
- or go back to the newest paste.
| 1 | // разработайте сигнатуру фунции MakeVector по аналогии с функцией MakeSet из урока | |
| 2 | #include <algorithm> | |
| 3 | #include <iostream> | |
| 4 | #include <set> | |
| 5 | #include <string> | |
| 6 | #include <vector> | |
| 7 | ||
| 8 | using namespace std; | |
| 9 | ||
| 10 | template <typename It> | |
| 11 | void PrintRange(It range_begin, It range_end) {
| |
| 12 | for (auto it = range_begin; it != range_end; ++it) {
| |
| 13 | cout << *it << " "s; | |
| 14 | } | |
| 15 | cout << endl; | |
| 16 | } | |
| 17 | ||
| 18 | template <typename It> | |
| 19 | auto MakeVector(It range_begin, It range_end) {
| |
| 20 | return vector(range_begin, range_end); | |
| 21 | } | |
| 22 | ||
| 23 | template <typename Container, typename Position, typename BeginRange, typename EndRange> | |
| 24 | void EraseAndPrint(Container& container, Position position, BeginRange beginrange, EndRange endrange) {
| |
| 25 | container.erase(begin(container) + position); | |
| 26 | PrintRange(begin(container), end(container)); | |
| 27 | container.erase(begin(container) + beginrange, begin(container) + endrange); | |
| 28 | PrintRange(begin(container), end(container)); | |
| 29 | } | |
| 30 | ||
| 31 | int main() {
| |
| 32 | vector<string> langs = {"Python"s, "Java"s, "C#"s, "Ruby"s, "C++"s};
| |
| 33 | EraseAndPrint(langs, 0, 0, 2); | |
| 34 | return 0; | |
| 35 | } |