C classic bubble sort implementation code
- 2020-04-02 02:06:33
- OfStack
void BubleSort(int* siSortArray, int siLen)
{
bool bSwapped = true;
do
{
bSwapped= false;
for(int i = 0; i < siLen - 1; i++)
{
if (siSortArray[i] > siSortArray[i+1])
{
int temp = siSortArray[i];
siSortArray[i]= siSortArray[i + 1];
siSortArray[i+ 1] = temp;
bSwapped= true;
}
}
}while(bSwapped);
}