Another confusing request...
I'm new at C++ and I'm trying to right a program that will generate random numbers from a range of 1-19. Here's how it should work, the program will generate 5 random numbers all ranged 1-19 and in random order. Once it chooses the first number, that number used for position 1(first number) cannot be used again, and after the second number is chosen it cannot be used again and so on. So basically it's like
postion one-19 possibilities
position two -18 possibilities (1-19 excluding position one number)
and so on until we get to position 5.
This claims you want random numbers, but this:
What I need is for the program to print out all possible combinations of these numbers.
claims you want all permutations. You can't do both. If you generate random numbers you can never be guaranteed to generate
all permutations randomly. I see 2 programs here
1) generate 5 random numbers
2) generate a list of permutations.
~s.o.s~ has basically given you the help you need for each question. Although I have to say that for readability
random_number = min + rand( ) % max ;
needs parentheses:
random_number = min + (rand( ) % max);
Reputation Points: 3278
Solved Threads: 894
Posting Sage
Online 7,744 posts
since May 2006