- #1
MathematicalPhysicist
Gold Member
- 4,699
- 371
i need to write functions that gives back the permutation of an integer.
i have already the factorial function in, so here what i did so far:
i can assume that MAXCOL is 7, you can assume that n<=7.
so far as you can see I am printing the list order i.e if n=2
then
now i want to be able to unchange the first line and then go to the second line and change it, and then change the third line that it wouldn't be identical to formers, and so forth.
the problem i don't know how to implement it, obviously some sorting is in place but which?
thanks in advance.
i have already the factorial function in, so here what i did so far:
i can assume that MAXCOL is 7, you can assume that n<=7.
Code:
int perm(int n)
{
MAXROW=fact(MAXCOL);
int perms[MAXROW][MAXCOL], i,j;
for(j=0;j<n;j++){
for(i=0;i<fact(n);i++){
perms[i][j]=j+1;
}
}
then
Code:
12
12
the problem i don't know how to implement it, obviously some sorting is in place but which?
thanks in advance.