#include <iostream> using namespace std;
#define N 10
void SimpleSelectionSort(int *a, int n) { int i, j, min_i, t; for (i = 0; i < n - 1; i++) { min_i = i; for (j = i + 1; j < n; j++) { if (a[min_i] > a[j]) { min_i = j; } } if (min_i != i) { t = a[i]; a[i] = a[min_i]; a[min_i] = t; } } }
int main() { int *a; a = new int[N];
for (int i = 0; i < N; i++) { cin >> a[i]; }
SimpleSelectionSort(a, N);
for (int i = 0; i < N; i++) { cout << a[i] << " "; } cout << endl; return 0; }
|