I would like to generate 100 randomly selected permutations for an array with 16 elements.
The array = <1, 2, 3, . . . 16>
void printarray(int A[], int size)
{
int i, j;
for(i = 0; i < size; i++)
cout << endl << A[i];
cout << endl;
}
void swap(int *a, int *b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
}
void permutation(int *A, int start, int end)
{
if(start == end)
{
printarray(A, end + 1);
return;
}
int i;
for(i = start; i <= end; i++)
{
swap((A + i), (A + start));
permutation(A, start + 1, end);
swap((A + i), (A + start));
}
}
I used this to find all the permutations for an array with 4 elements, with the array = <1, 2, 3, 4>. However, I cannot use this to find 100 random permutations for the array with 16 elements.
Additionally, is there a program that I could use to find ALL permutations of the array A = <1, 2, 3, 4> AND only 100 random permutations of another array A = <1, 2, 3, ..., 16>?