Algoritmy “move” a “swap”

{“https:\/\/www.jdoodle.com\/a\/clE?format=text”:”#include <iostream>\n#include <vector>\n#include <algorithm>\nusing namespace std;\n\ntemplate<typename C>\nvoid print(C container) {\n for(auto val : container)\n cout << val << ";";\n cout << endl;\n}\n\nint main() {\n auto generator = []() {\n static int value = 0;\n return value++;\n };\n vector<int> data;\n generate_n(back_inserter(data), 20, generator);\n print(data);\n \n auto itHalf = next(data.begin(), 10);\n swap_ranges(data.begin(), itHalf, itHalf);\n print(data);\n return 0;\n}”}


Algoritmy “move” a “swap”
Ohodnoťte tento článek