Dear All,

Was wondering if there is any way of generating the next values in an array to compute an np-complete system? Ok I know that sounds confusing but this is how it goes:
Say you have array[4]
First Array is : 1 2 3 4
Second Array: 1 2 4 3
Carries on like: 1 3 2 4; 1 3 4 2; 1 4 2 3; 1 4 3 2
Arrays: 123456
It’s real easy to draw out but was hoping there is a function, STL or something that can generate the next array from what the previous one was. I do know more or less how I will have to code it if there isn’t a function but really not looking forward to that. It will have something to do with Nested Recursive functions :(
Thanks in advance

the function(s) next_permutation in <algorithm> would generate the next permutation. you could call that repeatedly.

Cool thank you was looking for exactly that and it works perfectly.

Thank you very very much

This question has already been answered. Start a new discussion instead.