lundi 13 juillet 2015

Random numbers with no duplicates [duplicate]

This question already has an answer here:

I'm developing a Quiz app, and i need to propose random Questions. At the moment, i'm using this code to do this:

qid = Min + (int)(Math.random() * ((Max - Min) + 1));

Where "Max" is the maximum number that i want to be randomized, and "Min" is zero.

Unfortunately, my numbers repeat sometimes, and i don't want this to happen. Can someone help me?




Aucun commentaire:

Enregistrer un commentaire