I'm creating a function to generate an arry of random and not repeating numbers.What am i doing wrong?
With this code the function fills the array repeating some numbers.
for(int i=0;i<n;i++)
{
numero = random.nextInt(delta) + da;
for(int j=0;j<n;j++)
{
if(numero==estratti[j])
{
numero = random.nextInt(delta) + da;
j=0;
}
}
estratti[i] = numero;
}
Aucun commentaire:
Enregistrer un commentaire