Mail Archives: djgpp/1999/08/05/23:34:53
On 04 Aug 1999 16:41:58 GMT, orvbongat AT aol DOT com (Orvbongat) wrote:
>Hi, anyone who can send me a source or a place to get a source code
>or a C integer sorting routine or if you have one, please send it to
>
>orvbongat AT aol DOT com
>
>thanks
There's a lot of different ways... The simplest would probably be to
compare your first two, switch if the first is larger, etc.
#define SIZE 50
int array[SIZE], i, j;
for(i = 0; i < SIZE; i++)
printf("%i", array[i]);
for(i = 0; i < SIZE - 1; i++)
{
for(j = 0; j < SIZE - i; j++)
{
if(array[j] > array[j + 1])
swap(array[j], array[j + 1]);
}
}
That should work. The swap function is obvious.
Sean
- Raw text -