I need help creating Unique numbers in my random number generator. Each line of ticket should only display the a number once. Can anyone give me a hint as to how I can do this? I have only learned about functions and array's so I can't use anything beyond that.
I would like to apologize for the messy code since this is my first programming course.
I need help creating Unique numbers in my random number generator. Each line of ticket should only display the a number once. Can anyone give me a hint as to how I can do this? I have only learned about functions and array's so I can't use anything behind that.
Create an array that holds all values a ball might represent (1-56 for example.) Shuffle the array. Treat the first five values as the five balls that are picked.
It can be done either way. I would probably put it in its own function which might look similar to:
1 2 3 4 5 6 7 8 9 10 11 12 13
void do_picks(int* picks) // or void do_picks(int picks[]) is equivalent
{
// set up the ball pool
int ball_pool[ball_pool_size];
// ...
// shuffle it
// ...
// pick 'em
for (unsigned i = 0; i < num_picks; ++i)
picks[i] = ball_pool[i];
}