next_permutation 问题 c++
使用此代码时:
for(int i=0; i<line; i++) {
next_permutation(nums, nums+N);
if(DEBUG) {
for(int j=0; j<N; j++) {
cout << nums[j] << " ";
}
}
}
我得到以下输出: -1076591092_1_2_4_3_-1076591092_1_3_2_4_
Int his case, line will be 3, and N is 5; 谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 [-1076591092, 1, 3, 2, 4] 是
[-1076591092, 1, 2, 4, 3]
之后的下一个排列“http://www.cplusplus.com/reference/algorithm/next_permutation/”rel="nofollow">定义。[-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.