[HELP] get 10 biggest numbers in an array
#5

It's called bubble sorting

pawn Код:
bubbleSort(array[], length)
{
    new i,j;
    for(i=0;i<length;i++)
    {
        for(j=0;j<i;j++)
        {
            if(array[i]>array[j])
            {
                new temp=array[i]; //swap
                array[i]=array[j];
                array[j]=temp;
            }

        }

    }

}
pawn Код:
new array2[] = {1, 5, 3, 7, 5, 3, 2};
bubbleSort(array2, 7);
for(new i = 0; i < 7; i++)
{
    printf("%d",array2[i]);
}
will print
7 5 5 3 3 2 1
Reply


Messages In This Thread
[HELP] get 10 biggest numbers in an array - by N1trO - 06.12.2009, 15:27
Re: [HELP] get 10 biggest numbers in an array - by DeathOnaStick - 06.12.2009, 15:48
Re: [HELP] get 10 biggest numbers in an array - by MJ! - 06.12.2009, 15:53
Re: [HELP] get 10 biggest numbers in an array - by N1trO - 06.12.2009, 15:57
Re: [HELP] get 10 biggest numbers in an array - by dice7 - 06.12.2009, 16:50
Re: [HELP] get 10 biggest numbers in an array - by N1trO - 06.12.2009, 16:59
Re: [HELP] get 10 biggest numbers in an array - by yom - 06.12.2009, 17:16
Re: [HELP] get 10 biggest numbers in an array - by radhakr - 06.12.2009, 18:12

Forum Jump:


Users browsing this thread: 2 Guest(s)