//compare the consecutive numbers, larger one sinks to the bottom
void bubbleSort(int *a)
{
// int temp;
for(int j = 0; j < arraysize; j++)
{
for( int i = 0; i < arraysize - j - 1;i++ )
{
if( a[i] > a[i+1] )
{swap(a[i], a[i+1]);}
}
}
}
No comments:
Post a Comment