#include void Insert(int a[], int n, int x) {// Insert x into the sorted array a[0:n-1]. int i; for (i = n-1; i >= 0 && x < a[i]; i--) a[i+1] = a[i]; a[i+1] = x; } void InsertionSort(int a[], int n) {// Sort a[0:n-1]. int i,t; for (i = 1; i < n; i++) { t = a[i]; Insert(a, i, t); } } int main(void) { // defines the array with values int y[1000]; int n, minval, maxval,i; scanf("%d",&n); printf("The number of elements is: %d\n",n); //read and print the elements y[0] ... for (i=0; i< n; i++) { scanf("%d",&y[i]); printf("%d\n",y[i]); } printf("\n"); // computes the smallest and largest values in y[0] ... minval=y[0]; maxval=y[0]; for (i=0; i< n; i++) {if ( y[i] < minval ) minval = y[i]; if ( y[i] > maxval ) maxval = y[i]; }; // prints the smallest value in y[0] ... printf("The smallest value is: %d\n",minval); // prints the largest value in y[0] ... printf("The largest value is: %d\n",maxval); InsertionSort(y,n); // prints the values in sorted order printf("The sorted numbers are: \n"); for (i=0; i< n; i++) printf("%d\n",y[i]); printf("\n"); }