Hey guys this a program i am to write for my college professor and he has given me a list of N elements and i am to print all possible 5 combination of elements and print to a list. However, i was thinking
Code:
of using the rand() and srand() functions but since the number space is very large so rand() % N would produce repeated
sequences of 5 numbers so i just wanted help how how to develop this algorithm. Here is my code but i know it is not correct.
Code:
int Permutate_Numbers(int Array[], int n)
{
for( int i = 0; i < N C 5; i++)//counts right up to NCombination 5...doubt here??
{
srand(time(NULL));
for( int j = 0; j < 5; j++)
Result[i][j] = rand() % 5;
}
return 0;
} //but i have to make sure no number repeates on the same
sequence list and no sequence list repeats subsequently... well i am not really sure about my algorithm or do i need to do some permutations again to be able to get all the possible 5 combinations of the 18 elements... thanks for the help...