/* bubble.c -- Read an integer array, print it, then sort it and * print it. Use the bubble sort method. */ #include #define NMAX 10 int getIntArray(int a[], int nmax, int sentinel); void printIntArray(int a[], int n); void bubbleSort(int a[], int n); int main(void) { int x[NMAX]; int hmny; int who; int where; hmny = getIntArray(x, NMAX, 0); if (hmny==0) printf("This is the empty array!\n"); else{ printf("The array was: \n"); printIntArray(x,hmny); bubbleSort(x,hmny); printf("The sorted array is: \n"); printIntArray(x,hmny); } } void printIntArray(int a[], int n) /* n is the number of elements in the array a. * These values are printed out, five per line. */ { int i; for (i=0; ia[lcv+1]) { temp = a[lcv]; a[lcv] = a[lcv+1]; a[lcv+1] = temp; lastChange = lcv; } limit = lastChange; } }