I have a program that I am to use permute to get all permuation of the numbers {0-9}. I have can do this with next_perumation but that starts on the right and moves to the left. I would like to start on the left and move to the right because I need just the firts 7 numbers ( to check a math problem). I was given the code
but when I run if I add a cout I do not get the permutations. Will this work or is there a way to use next_permutatio n that will start on the left side?
Code:
void permute (int v[], int curr )
{
if ( curr >= MAX )
checkit(v);
else
for ( i = curr; i < MAX; i++ )
{
swap (v[i],v[curr]) // interchange the thing at location i with the value at curr
permute(v,curr + 1);
swap (v[curr], v[i])
}
} // permute
Comment