// ***************************************************************** // Author: Zhixiang Chen // Class: CSCI/CMPE 1170, Spring 2009 // Lab 24: Bubble sort // Date: January 12, 2009 // Comment: The code here is meant to be revised. // ***************************************************************** #include #include #include #include #include using namespace std; #ifndef LAB_24_HEAD_H #define LAB_24_HEAD_H /*********************************************************************** This function generates SIZE many integers in the range of 0 and 99 and loads these random integer to the list ***********************************************************************/ void loadList(int list[], const int SIZE) { unsigned seed; //get a random seed cout<<"Enter a random seed => "; cin>>seed; srand(seed); //generate random numbers and load them to the list for (int i=0; i list [j+1]) //list[j] and list[j+1] are in wrong order { swap = true; //one swap happened temp = list[j]; //the three statements do swaping list[j] = list[j+1]; list[j+1] = temp; count++; //record the comparisons } } if(!swap) //no swap in the current pass break; //means the list is sorted so break out } //finish and stop return; } /************************************************************************ this function print all numbers in the list. ************************************************************************/ void showList(const int list[], const int SIZE) { cout<<"The list is ..... " <