bubble_sort
#include <stdio.h>
void swap(int *a, int *b)
{
int *temp;
temp = *a;
*a = *b;
*b = temp;
}
void bubble_sort(int *array, int n)
{
int i = 0;
int j = 0;
for(i = 0; i < n; i++)
for(j = 1; j < n-i; j++)
{
if(array[j-1] > array[j])
swap(&array[j-1] , &array[j]);
}
}
int main(void)
{
int i = 0;
int array[10] = {3, 5, 2, 7, 1, 9, 0, 4, 8, 6};
bubble_sort(array, 10);
for(i = 0; i < 10; i++)
{
printf("%d\n", array[i]);
}
return 0;
}