09-04-2011, 07:15 AM
Inverse Permutation Question in c++ 2011-12
Inverse permutations from an array of permutations. It's my first time coding on permutations so I don't have any experience on this. So I came up with a solution to just swap the array and the element number as the inverted permutation
v
Inverse permutations from an array of permutations. It's my first time coding on permutations so I don't have any experience on this. So I came up with a solution to just swap the array and the element number as the inverted permutation
v
Code:
oid inverse ( unsigned ip[], const unsigned p[], unsigned elements ) {
unsigned tempArray = 0, tempIndex = 0;
for (int i = 0; i < elements; i++ ) {
tempIndex = i;
tempArray = p[i];
ip[tempArray] = tempIndex;
}
show ( ip, 5 );
}0300-9520262
Get solution in 24 hour |cpmputer & internet
mileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
