I want my program to have numbers 1 through 10. I want it to have a sets of 5 numbers and list all the combinations that it can have. I don't want one number to be use twice in a set. This is what i have so far.
-
array [x]
-
int x = 0;
-
x = rand();
-
-
while (x<0 && x<10)
-
I am confuse with your question. Do you mean you want to store numbers between 1 to 10 in your array ? if it is the case, you can use : 1+ (rand()%10). This will randomly generate a number between 1 to 10 only one at a time. if you want to initiliaze (fill) your element within your array with integer, you will need a for loop to do it for you. For example:
-
for( i = 0 ; i < 10; ++i)
-
array[i] = 1 + (rand() %10)
-
Next, you mean you want to have a set of 5 numbers ? is it 5 element within your array ? i am not sure does rand() generates unique number always, but you can try srand() which take in current system time as an parameter, thus, generates unique number from time to time.