daily pastebin goal
48%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void SelectionSort( int suspectName[], int numberOfCrooks )
  2. {
  3.     int smallestIndex;
  4.     int index;
  5.     //Step through each element in the array
  6.     for ( index = 0; index < numberOfCrooks - 1; index++ )
  7.     {
  8.         for (index < 0; index < numberOfCrooks - 1; index++)
  9.         {
  10.  
  11.         }
  12.  
  13.         //Locate the smallest value in the array from index to arraySize
  14.         smallestIndex = IndexOfSmallest ( suspectName, numberOfCrooks, index );
  15.         //Swap the value at index with the smallest value at smallestIndex
  16.         Swap( suspectName[index], suspectName[smallestIndex]);
  17.     }
  18. }
  19.  
  20.     int IndexOfSmallest(int list[], int arraySize, int index)
  21. {
  22.     int smallestIndex = index;
  23.     int minIndex;
  24.     //Step through the array checking to see if any value is smaller
  25.     //than the value at smallestIndex
  26.     ///smallestIndex is the current first value in this part of the array
  27.     for ( minIndex=index+1; minIndex < arraySize; minIndex++)
  28.     {
  29.         if (list[minIndex] < list[smallestIndex])
  30.         {
  31.             smallestIndex = minIndex;
  32.         }
  33.     }
  34.     return smallestIndex;
  35. }
  36.  
  37. void Swap( int& first, int& second)
  38. {
  39. int temp;
  40. //Exchange the two values
  41. temp = first;
  42. first = second;
  43. second = temp;
  44. }
RAW Paste Data
Top