tags:

views:

42

answers:

1

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

+5  A: 

Check std::next_permutation.

KennyTM