/** * selectionsort.cpp * 30apr07/sklar * * this program demonstrates the selection sort algorithm. * */ #include #include #include using namespace std; // declare constants const int NUM_DICE = 5; const int NO_DICE = 7; // declare global variable int dice[NUM_DICE]; // declare function prototypes void initDice(); void printDice( int d[], int n ); void swapDice( int a, int b ); int findMin(); void selectionSort(); /** * initDice() * * this function initializes the values in the array of dice to * integers between 1 and 6 * */ void initDice() { for ( int i=0; i 0 ) { min = findMin(); aux[aux_end] = dice[min]; aux_end++; dice[min] = NO_DICE; num_unsorted--; num_passes++; cout << "after pass #" << num_passes << ": "; printDice( aux, aux_end ); } // end while for ( int i=0; i