This content presents you with some possible coding method for permutation. I don’t create them by myself. Instead of that, I’ve just bring some interesting algorithms to present here.

- Alexander Bogomolyn’s unordered permutation algorithm
#include <stdio.h>
void visit(int *Order, int N,int k){
static int level=-1;
level+=1;Order[k]=level;
if(level==N) print(Order,N);
// function print for printing all elements in Order
else
for(int i=0;i<N;i++)
if(Order[i]==0) visit(Order,N,i);
level=level-1;Order[k]=0;
}
main(){
const int N=4;
int Order[N];
for(int i=0;i<N;i++) Order[i]=0;
visit(Order,N,0);
}

### Like this:

Like Loading...

*Related*