I dont know if it is asked (I couldn't find any).
I want to iterate on this kind of numbers implemented on array;
int a[10];
int i = 0;
for( ; i < 10; i++ )
a[i] = i+1;
now the array has
"1 2 3 4 5 6 7 8 9 10" and I want to get "1 2 3 4 5 6 7 8 10 9" and then "1 2 3 4 5 6 7 9 8 10" "1 2 3 4 5 6 7 9 10 8" . . . .I tried to get an algorithm but I couldn't figure it out. Is there an easy 开发者_运维技巧way to implement "next" iterator for this kind of problems?
Thanks in advance
Check std::next_permutation
.
精彩评论