28.04.2017, 15:36
I'm pretty sure it's optimizable :
Also, change 50 by the max number you will generate in your script
PHP код:
DistinctNumber(number)
{
new
string[50],
count,
bool:sameNB = false;
do
{
string[count] = random(number);
for(new i; i < number; i++)
{
if(count == i)
continue;
if(string[count] == string[i])
sameNB = true;
}
if(!sameNB)
count++;
sameNB = false;
}
while(count != number);
return string;
}