Random number

closed account (oLC9216C)
I was trying to make 16 random number That is from 1-8.And every number should show twice, how can I make it? The only thing I know is

1
2
for(int i=0;i<16;i++)
 number[i] = rand() % 8 + 1;

but some number never shows or shows more than two times.
well for one. You are missing your srand(time(NULL)) and for two making it so it will only pick a number twice is a bit more complicated than that.
You would have to check when a number is called and if it calls that number after the second time then to call another number until all numbers are called twice
Topic archived. No new replies allowed.