开发者

next_permutation problem c++

开发者 https://www.devze.com 2023-02-08 17:27 出处:网络
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++) {

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!


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


The problem is related to poor memory management.

0

精彩评论

暂无评论...
验证码 换一张
取 消