#include <stdio.h>
void bubblesort( int *ptr, int size );
void swap( int *bef, int *next );
int main()
{
int num[] = {2,4,1,43,23,42,645,12,98,65};
int size;
int i;
size = 11;
for( i=0; i<(size-1); i++ )
printf( "%d ", num[i] );
bubblesort( num, size );
puts( "/n" );
return 0;
}
void swap( int *bef, int *next )
{
int temp;
temp = *bef;
*bef = *next;
*next = temp;
}
void bubblesort( int *ptr, int size )
{
int i;
int j;
int count;
count = size - 1;
for( i=0; i<count; i++ )
{
for( j=0; j<count; j++ )
{
if( ptr[j] > ptr[j+1] )
swap( &ptr[j], &ptr[j+1] );
}
}
}