What I want to do is to find every permutation of a 1-d array with repetitions of its contents.
e.g.
int array[]={1,2,3};
for(i=0;i<3;i++){
next_permutation(array,array+3)
for(int j=0;j<=3;j++){
printf("%d ",array[j]);
}
printf("\n");
}
will return:
1 2 3
1 3 2
2 1 3
etc...
what I want the function to return:
1 1 1
1 1 2
1 2 1
2 1 1
1 2 2
2 2 1
2 1 2
1 1 3
1 3 1
3 1 1
etc...
Is there a function that can do that?
Thanks in advance, Erik