#include #include #include template void straight_selection(std::vector &array) { for (int i = 0; i < array.size(); ++i) { for (int j = i; j < array.size(); ++j) { if (array[j] < array[i]) { std::swap(array[i], array[j]); break; } } } } template std::ostream & operator<<(std::ostream &stream, std::vector &v) { if (v.size() == 0) stream << "{ }"; stream << "array = { "; for (int i = 0; i < int(v.size()) - 1; ++i) stream << v[i] << ", "; stream << v.back() << " }"; return stream; } int main() { std::vector array = { 2, 7, 12, 30, 11, 4, 12, 5, 20 }; std::cout << array << std::endl; straight_selection(array); std::cout << array << std::endl; return 0; }