Hello, Michael!
12 Jan 98, Michael Rathburn wrote to All:
:MR> //sort
:MR> int temp, test = 0;
:MR> while(test == 0)
:MR> {
:MR> test = 1;
:MR> for (i = 0; i < (MAX - 1); i++)
:MR> {
:MR> if (table[i] < table[i + 1])
:MR> {
:MR> temp = table[i];
:MR> table[i] = table[ i + 1];
:MR> table[i + 1] = temp;
:MR> test = 0;
:MR> }
:MR> }
:MR> }
You are looking through array (untill it is sorted = test==1 et the end of
while-cycle), finding couples in wrong order and do position exchange for
them. For example:
3 1 4 1 5 9
3 4 1 1 5 9 3 4 1 1 9 5
4 3 1 1 9 5 4 3 1 9 1 5 4 3 1 9 5 1
4 3 9 1 5 1 4 3 9 5 1 1
4 9 3 5 1 1 4 9 5 3 1 1
9 4 5 3 1 1 9 5 4 3 1 1
Not very effective but it is work.
Alexey
--- GoldED 3.00.Alpha4+
---------------
* Origin: St_1, St.Petersburg Russia (2:5030/155.19)
|