Solved rearrange array in C++

Signed-off-by: Ionut Radu <ihonius@gmail.com>