TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: MICHAEL RATHBURN
from: BRIAN WOOD
date: 1998-01-15 11:33:00
subject: sort algorithm

 MR> Hi All , hope you are having a nice day
So far, so good!  Thanks.
 MR> Can someone explain how this sort works I have tried to follow it
 MR> but I just get confused.

 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> }
That's a good one, I didn't think it would work, but it does.  Seems to
go through the entire array, moving higher values to the left, setting
test=0 if there was a sort performed, so the while loop gets performed
again on the entire array.  Thanks for the loop!
L8r,
bw
... Don't steal.  The government hates competition.
--- Blue Wave/DOS v2.20
---------------
* Origin: River Canyon Rd. BBS Chattanooga, Tn (1:362/627)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.