Consider an array. What is a good way to permute its elements according to another array that gives the new positions of elements (without making a copy of the array first)?

For example

```
int a[]={37,43,5,10}; //array to permute
int b[]={3,1,4,2};  //new position of each element

```

so a should become

```
{43,10,37,5}

```

I naturally thought about making a copy of a and then re allocate its element in the new positions. But is there a way to do it without making a copy of the array a (i.e. a more simple way)?

**Note**: If possible the way to do it should not use particular C++ headers but only `<iostream>`