Permutation Arrays |
In many computer problems, it is necessary to permute data arrays. That is, the data in an array
must be re-arranged in some specified order. One way to permute arbitrary data arrays is to specify
the permutations with an index array. Let x be an array that is to be permuted and let x' be the permuted array. Then, we have the relationship between x and x' that .
The input file will contain two lines of numbers. The first line will be an index array containing
the integers , where n is the number of integers in the list. The numbers in the first line will have been permuted in some fashion. The second line will contain a list numbers in floating point format.
The output for this program will be the list of floating point numbers from the input file, ordered according to the permutation array from the input file. The output numbers must be printed one per line in the same format in which they each appeared in the input file.
3 1 2 32.0 54.7 -2
-2 32.0 54.7