TM> If you think that bubble sort is a good sorting algorithm, I have to
TM> object.
If you have a better one, then why not share it? For the price of a few
lines, I thought it was a very interesting example. Below is the way I
learned bubblesort. Good excercise for understanding pointers and the
address-of operator. The other used a different loop strategy, which is
why I thought it was a good example.
// bubbleSort( int *array, int size)
void bubbleSort(int *a, const int s)
{
void swap(int *, int *);
for(int p=1; p a[j+1])
swap(&a[j], &a[j+1]);
}
void swap(int *a, int *b)
{
int t=*a;
*a=*b;
*b=t;
}
L8r,
bw
... I couldn't possibly fail to disagree with you less.
--- Blue Wave/DOS v2.20
---------------
* Origin: River Canyon Rd. BBS Chattanooga, Tn (1:362/627)
|