PERMUTATION problem

solved with next_permutation() function in <algorithm> header file.