joshim5
joshim5

Reputation: 2255

next_permutation problem c++

While using this code:

for(int i=0; i<line; i++) {
    next_permutation(nums, nums+N);
    if(DEBUG) {
        for(int j=0; j<N; j++) {
            cout << nums[j] << " ";
        }
    }
}

I am getting this output: -1076591092_1_2_4_3_-1076591092_1_3_2_4_

Int his case, line would be 3, and N is 5; Thanks!

Upvotes: 0

Views: 558

Answers (2)

joshim5
joshim5

Reputation: 2255

The problem is related to poor memory management.

Upvotes: 0

dalle
dalle

Reputation: 18507

[-1076591092, 1, 3, 2, 4] is the next permutation after [-1076591092, 1, 2, 4, 3], according to definition.

Upvotes: 2

Related Questions