22 lines
308 B
C
22 lines
308 B
C
// Bubblesort Algorithm
|
|
// M.Menault 2024
|
|
|
|
void bubblesort(int* array, int length)
|
|
{
|
|
int swapped, i, tmp;
|
|
do
|
|
{
|
|
swapped = 0;
|
|
for(i=1;i<length;i++)
|
|
{
|
|
if(array[i-1] > array[i])
|
|
{
|
|
tmp = array[i-1];
|
|
array[i-1] = array[i];
|
|
array[i] = tmp;
|
|
swapped++;
|
|
}
|
|
}
|
|
} while(swapped==1);
|
|
}
|