Mega Code Archive
Bubble sort
#include
#define MAX 10
void swap(int *x,int *y)
{
int temp;
temp = *x;
*x = *y;
*y = temp;
}
void bsort(int list[])
{
int i,j;
for(i=0;i<(MAX-1);i++){
for(j=0;j<(MAX-(i+1));j++){
if(list[j] > list[j+1]){
swap(&list[j],&list[j+1]);
}
}
}
}
void printlist(int list[])
{
int i;
printf("The elements of the list are: \n");
for(i=0;i