you could also use a regular array with this instead of vector.begin() you'd do something like begin(array).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <vector>
#include <iostream>
#include <algorithm>
usingnamespace std;
vector<int> i{ 1,2,3,4,5 };
auto min = min_element(i.begin(), i.end());
auto max = max_element(i.begin(), i.end());
swap(*min, *max);
for (auto m : i) {
cout << m;
}