Arrangement.
#5

You could try this out...took me a minute to write it out (with testing and all lol)

pawn Код:
stock BubbleSort(Array[], size) //at least similar
{
    new tmpslot=0, bool:swapped;
   
    redo:
    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;
        }
    }
    if(swapped) goto redo;
   
    for(new index=0; index < size; index++) printf("Number %d: %d", index+1, Array[index]);
}
EDIT: this is what i used to test it

pawn Код:
new TestArray[10] = {4,3,6,2,7,1,5,9,8,10};
main()
{
    BubbleSort(TestArray, 10);
}
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: 2 Guest(s)