#include #define SIZE 10 void select_sort(int list[], int n); int get_min_range(int list[], int first, int last); void read_array(int list[], int n); void print_array(const int list[], int n); int main() { int arr[SIZE]; read_array(arr, SIZE); printf("Original array values:\n"); print_array(arr, SIZE); select_sort(arr, SIZE); printf("\nSorted array values:\n"); print_array(arr, SIZE); return 0; } /* * Sorts the data in array list * Pre: first n elements of list are defined and n >= 0 */ void select_sort(int list[], /* input/output - array being sorted */ int n) /* input - number of elements to sort */ { int fill, /* first element in unsorted subarray */ temp, /* temporary storage */ index_of_min; /* subscript of next smallest element */ for (fill = 0; fill < n-1; ++fill) { /* Find position of smallest element in unsorted subarray */ index_of_min = get_min_range(list, fill, n-1); /* Exchange elements at fill and index_of_min */ if (fill != index_of_min) { temp = list[index_of_min]; list[index_of_min] = list[fill]; list[fill] = temp; } } } /* * Find the smallest element in the sub-array list[first] * through list[last], where first"); for (i = 0; i < n; ++i) scanf("%d", &list[i]); } /* function to print an array of n elements */ void print_array(const int list[], int n) { int i; for (i=0; i