Quote Originally Posted by flp1969 View Post
Almost the same way you tried:
Code:
n = (rand() % 49)+1;
Taking the remainder of a division by 49 you'll get a value between 0 and 48 (inclusive), so you just need to add 1.

"Random" doesn't mean "don't repeat"... So, if you don't want repetition you must keep track of previously generated values.

Which is the same as writing:
Code:
rand() % 50
and it is not what you wanted.

Yep, it is possible and simple to do... good luck!
And some steps?
I found something like this,is this a good start?
''To pick lotto numbers, you make a pool (an array) of available numbers, pick one of them (an index) at random, and remove that number from the pool, by swapping it with the top one and then decreasing the number of items available. If you want a different selection each run, you call srand(time(NULL)) once at the start of the program. If you want to debug the same sequence, don't.''