Arrangement.
#7

Quote:
Originally Posted by Vince
Посмотреть сообщение
Don't ever use goto! Use do-while in this case.
pawn Код:
do
{
    // ..
}
while(swapped);
lol facepalm i just realized why it wasn't working when i was using the do while


pawn Код:
stock BubbleSort(Array[], size) //at least similar
{
    new tmpslot=0, bool:swapped;


    do
    {
        swapped = false;
        for(new index=1; index < size; index++)
        {
            if(Array[index-1] > Array[index])
            {
                tmpslot = Array[index];
                Array[index] = Array[index-1];
                Array[index-1] = tmpslot;
                swapped = true;
            }
        }
    } while(swapped);
   
    for(new index=0; index < size; index++) printf("Number %d: %d", index+1, Array[index]);
}
The version with the do while instead of goto...though I don't really see a difference between the two.
Reply


Messages In This Thread
Arrangement. - by nuriel8833 - 09.05.2012, 08:58
AW: Arrangement. - by EnzoMortelli - 09.05.2012, 09:05
Re: AW: Arrangement. - by nuriel8833 - 09.05.2012, 09:11
Re: Arrangement. - by aco_SRBIJA - 09.05.2012, 09:58
Re: Arrangement. - by [ABK]Antonio - 09.05.2012, 10:06
Re: Arrangement. - by Vince - 09.05.2012, 10:11
Re: Arrangement. - by [ABK]Antonio - 09.05.2012, 10:15
Re: Arrangement. - by nuriel8833 - 09.05.2012, 11:03
Re: Arrangement. - by [ABK]Antonio - 09.05.2012, 11:05
Re: Arrangement. - by [ABK]Antonio - 09.05.2012, 11:28

Forum Jump:


Users browsing this thread: 1 Guest(s)