#include using namespace std; void swap(int array[], int i, int j) { int temp = array[i]; array[i] = array[j]; array[j] = temp; } int minIndex(int array[], int low, int high) { int answer = low; for (int c = low; c <= high; c++) if (array[c] < array[answer]) answer = c; return answer; } void sort(int x[], int capacity) { for (int step = 0; step <= (capacity - 1); step++) { int index = minIndex(x, step, capacity - 1); swap(x, step, index); } } void printArray(int y[], int capacity) { for (int c = 0; c <= (capacity - 1); c++) cout << y[c] << " "; } int main() { int x[10] = {7, 90, 2, 45, 4, 1, 60, 34, 99, 10}; int y[5] = {2, 45, 4, 1, 60}; cout << "Unsorted x and y:\n"; printArray(x, 10); cout << endl; printArray(y, 5); cout << endl; sort(x, 10); sort(y, 5); cout << " Sorted x and y:\n"; printArray(x, 10); cout << endl; printArray(y, 5); cout << endl; return 0; }