void SelectionSort(int values[], int numValues) {
int endIndex = numValues ¡V 1;
for (int current=0; current<endIndex; current++)
Swap(values[current],
values[MinIndex(values, current, endIndex)]);
}
count++;
swap(arr[alphabetical], arr[index1]);
}
}
void swap(int &a, int &b)
{
int temp;
temp = a;
a = b;
b = temp;
}
int main()
{
int a[5]={john,mary,ryan,hannah,bob};
int counta = 1;
//for an array of size 5
cout<<"This is the array unsorted: "<<endl;
for (int i = 0; i < 5; i++)
{
cout<<a[i]<<" ";
}
cout<<endl;
selsort(a, 5, counta);
cout<<"This is the array sorted: "<<endl;
for (int i = 0; i < 5; i++)
{
cout<<a[i]<<" ";
}
cout<<endl<<"It took "<<counta<<" swaps to sort it."<<endl<<endl;