How would I write a permutation method in C programming with an array of string characters while each character is being mapped to an integer? So for example, I have a permutation of 10 integers:
1, 0, 2, 3, 5, 4, 6, 9, 8, 7 - not necessarily in order
and a text full of characters, less than 400 characters. I have both of them stored into 2 separate arrays, but how would I map each integer onto each character? After mapping them, how would I go about writing a method of permutation?
Neither arrays are the same size. The permutation array has 10 values, the char array has less than 400 chars, but I just initialized it as: char text[400]; the size of each arrays do not move.
Better explanation:
I was thinking, if I have 10 integers (0 - 9) and the following permutation - where each permutation cannot have the same number:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9 - original
1, 0, 3, 6, 7, 4, 5, 9, 2, 8 - permutation
Apple, bee - text of 10 characters, including the space and comma
so by applying the permutation above, I would get something like:
'pAl be,epe'
And if you use the inverse of that permutation, you would get 'Apple, bee' again.
The original index[0] is where the 'A' in Apple is supposed to be - and with the permutation, it is switched with the 'p' because of the 1 index... and so on.
So how would I go about implementing that? In other words, how would I map the permutation to each char and have it switch positions? I haven't learned about Structures yet.