/***************************************************************************** * Sorts an array of predetermined numbers, using the buble sort. * * Inputed: * * Outputed: mainarray * * Written: July 12, 2002 * * By: Ronald Roberts * *****************************************************************************/ /* Compiler Directives */ #include #include #include #include #include /* Bubble Sort Algorithm */ void bubble_sort (int array[], int arrayLength); void bubble_sort (int array[], int arrayLength) { int i, j, flag=1; int temp; for (i=1; (i<=arrayLength) && flag; i++) { flag =0; for (j=0; j< (arrayLength - i); j++) { if (array[j+1] > array [j]) { temp=array[j+1]; array[j+1]=array[j]; array[j]=temp; flag=1; } } } } /* Main Code */ int main() { int mainarray[9]={3, 8, 5, 2, 0, -3, 19, 14, 7}; bubble_sort(mainarray, 9); cout<<"These Numbers have been sorted in order."<