SA-MP Forums Archive
Get the Biggest number? - 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: Get the Biggest number? (/showthread.php?tid=142172)



Get the Biggest number? - WackoX - 17.04.2010

When i have this for example:

Код:
new Float:Test[10][1] = {
{0},
{0},
{7},
{1},
{8},
{4},
{2},
{3},
{3},
{8}
};
How can i get the bigest number out of it?







I though of something like this, but would that work?
Код:
GetBigestNumber()
{
	new number;
	for(new k; k < MAX_MAPS; k++)
	{
		for(new d; d < MAX_MAPS; d++)
		{
			if(Test[k] >= Test[d]) number = Test[k];
		}
	}
	return number;
}



Re: Get the Biggest number? - MadeMan - 17.04.2010

pawn Код:
GetBiggestNumber()
{
    new number;
    for(new k; k < sizeof(Test); k++)
    {
        if(Test[k] > number) number = Test[k];
    }
    return number;
}



Re: Get the Biggest number? - WackoX - 17.04.2010

Quote:
Originally Posted by MadeMan
pawn Код:
GetBiggestNumber()
{
    new number;
    for(new k; k < sizeof(Test); k++)
    {
        if(Test[k] > number) number = Test[k];
    }
    return number;
}
Yes thanks, but what if there are 2 number the same hight, or all numbers are 0 (zero)?


Re: Get the Biggest number? - MadeMan - 17.04.2010

What about it?


Re: Get the Biggest number? - GforceNL - 17.04.2010

Quote:
Originally Posted by MadeMan
What about it?
i think Wackox Means:

When the round has ended, The players need to choose a new map.
What if 2 maps are Both voted 5 times, What will happen Then?
or nobody vote, and all the maps are voted 0 times, What will happen then?

Sorry for bad English, Iam dutch :P