ネタ元 → [C++] 選択ソート
#include <algorithm>
template<typename Iterator>
void SelectionSort(Iterator first, Iterator last) {
for ( ; first != last; ++first ) {
std::iter_swap(first, std::min_element(first,last));
}
}
// おためし
#include <iostream>
int main() {
const int N = 10;
int data[N] = { 1, 3, 5, 7, 9, 8, 6, 4, 2, 0 };
SelectionSort(data, data+N);
for ( int i = 0; i < N; ++i ) {
std::cout << data[i] << ' ';
}
}
...ごめんなさい、ズルしました。