vendredi 20 mars 2015

Modify duplicating random number generator to non-duplicating random number generator


int size = 5;

int[] list = new int[size];

Random rand = new Random();
for(int i = 0; i < size; i++)
{
list[i] = rand.nextInt(100);
}

for(int element : list)
System.out.print(element + " ");


I'm trying to modify this random number generator so that it will not duplicate random generated numbers. How can I accomplish this? Thanks for your help.


Aucun commentaire:

Enregistrer un commentaire