[HELP] get 10 biggest numbers in an array - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] get 10 biggest numbers in an array (
/showthread.php?tid=112248)
[HELP] get 10 biggest numbers in an array -
N1trO - 06.12.2009
sombody have an idia how can i find the biggest 10 numbers in an array?
TNX for the help =]
Re: [HELP] get 10 biggest numbers in an array -
DeathOnaStick - 06.12.2009
Maybe you create a loop that checks what number is bigger than the other... Then save it in arrays....
Re: [HELP] get 10 biggest numbers in an array -
MJ! - 06.12.2009
Lol , the first ten biggest numbers ? Are you kidding ?
Re: [HELP] get 10 biggest numbers in an array -
N1trO - 06.12.2009
Quote:
Originally Posted by Щә яә Ґя
Lol , the first ten biggest numbers ? Are you kidding ?
|
whats the joke?
i will give you an example:
i have an array that contains the numbers:
1
2
7
78
3
8
10
58
56
23
4
7
1
2
and i want to put in another array the first biggest numbers like this:
78
58
56
23
10
8
7
7
4
3
2
2
Re: [HELP] get 10 biggest numbers in an array -
dice7 - 06.12.2009
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
Re: [HELP] get 10 biggest numbers in an array -
N1trO - 06.12.2009
TNX Dude =]
Re: [HELP] get 10 biggest numbers in an array -
yom - 06.12.2009
Bubble sort is just one of many sorting algorithm, and is far to be the best..
Re: [HELP] get 10 biggest numbers in an array -
radhakr - 06.12.2009
I'm not to sure about this and I've never tried it, but I think this might be relevant/useful for you:
https://sampwiki.blast.hk/wiki/Advanced_Structures#Lists