Random Generator Needed.

Soldato
Joined
17 Jan 2006
Posts
2,890
Location
Dundee
Does anyone know of a random generator that I can use that will be able to remember each number generated and not generate it again.

What I need it to do is to generate a number between 1 and ,say, 128 and report that number and then select a new number but knows not to pick the first number reported and so on until all numbers are used.

It is to be used for a random draw for a large pool tournament that I'm controlling.

Cheers.
 
Code:
int i = 0, j = 0, rand, *one, boolean = 1, Asize = 128;


one = calloc(Asize, sizeof(int));

for (i = 0; i < Asize; i++) {
  while (boolean) {
    rand = random(Asize);

    for (j = 0; j < Asize; j++) {
      if (one[j] == rand)
        break;
     }
     if (j == Asize)
       boolean = 0;
   }
   one[i] = rand;
}

print....
Something like that would work.


How would that work and where would I put it?

I am looking for something that I can drawn on the fly as it where.

Press a button on the laptop, get a number, announce it and repeat.

I can get umpteen lists of random numbers but this needs to be drawn live.
 
Back
Top Bottom