how can I make a random array, that has a random value which occurs only once per array
in
Programming Questions
•
1 year ago
how can I make a random array, that has a random value which occurs only once per array.
int[] randomarray = new int[18];
int check;
for (int i = 0; i<18; i++) {
check=0;
randomarray[i] = int(random(0, 20));
while (check<18) {
if (randomarray[i] == randomarray[check]) {
randomarray[i] = int(random(0, 20));
check=0;
}
else {
check++;
}
}
}
thanks in advance! :)
1