1
0
This commit is contained in:
2024-09-03 08:26:03 +02:00
parent fe64cb7aa5
commit b8c6f517fc
3 changed files with 30 additions and 2 deletions

21
bubblesort.c Normal file
View File

@@ -0,0 +1,21 @@
// 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);
}