0

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
e.g.
Arrays: 123456
111111
223344
342423
434232
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

2
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by JINX_
0

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

0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.