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. What I need is for the program to print out all possible combinations of these numbers. I know thats gonna be a ton of results, but it's what I need. So if anyone can help me? I know I need to use an array to get unique numbers for each position and all, I just don't know how to do it. Here's the program I have so far, it just prints out one random number 1-19:
int main()
{
srand((unsigned)time(0));
int a;
int lowest=1, highest=19;
int range=(highest-lowest)+1;
for(int index=0; index<1; index++){
a = lowest+int(range*rand()/(RAND_MAX + 1.0));
cout << a << endl;
}
}