/***************************************************************************** * Sorts an array of ints, in ascending order, using bubble sort. * * Inputed: * * Outputed: mainarray * * Written: July 12, 2002 * * By: Ronald Roberts * *****************************************************************************/ /* Compiler Directives */ #include #include #include #include #include /* Bubble Sort Algorithm */ void bubble_sort_ascending (int array[], int arrayLength); void bubble_sort_ascending (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[10]={1, 4, 5, 446, -99, 4, 7, 8, 9, 3}; bubble_sort_ascending(mainarray, 10); cout<<"These numbers are ordered in Ascending order."<