Permutation of char array In C -


I am working on an algorithm that searches for all permutations of elements of four arrays for a few days and Ok just do not seem to work.

The four array is a ** array, which I repeat based on the number entered by the user and then the malloc location for each word (every 40 characters) Is the number entered by the user, the length of the array , And this is the number that they expect to enter. This part works as expected.

The problem I am facing is running through four arrays and calculating the permutation of the entire set (array **). I again want to combine all the permutations of the set to another character array. Now the permutation of the unit index ** array, not individual letters of each index.

Does anyone have any suggestions on how to successfully do this regardless of the size of the initial set? I believe if the set size is stable, then it will be very easy.

My initial array looks like this in an example

  char * array [] = {"hello", "calculator", "pencil", "school Bus"}; In the array, with the "Hello" in the array [0] and "School Bus" [3], ** will be in the array, with '\ 0' at the end of each.  

I want to be on the syndrome index , character is not.

So

So

> "Hello"

Here is a dumb permutation generator Is (up to N = 32 ... or 64).

  Add # & lt; Stdio.h & gt; Const int N = 5; Int x [N]; Int main (zero) {int i, j; X [0] = - 1; Unsigned mask = -1; // (i = 0 ;;) {for (j = x [i] +1; j & lt; n; j ++) {// balance remaining if check ((mask >> gt; & gt; j) & Amp; 1) {/ // bit H1 is - & gt; Yet x [ii] = j; // Store number mask ^ = (1  = N) {for (j = 0; j & lt; n; j ++) printf ("% 3i", x [j]); Printf ("\ n"); } And x [i] = - 1; // start the next cell from the brake; }} // If there are no more numbers or cells, then (/ (H & gt; = N) || (i> = N)) (if (-i> l =;) break; mask ^ = (1 & lt; & lt; x [i]);}}}  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -