c++ - next_permutation 问题 c++

标签 c++ stl permutation

使用这段代码时:

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_

在他的例子中,line 是 3,N 是 5; 谢谢!

最佳答案

[-1076591092, 1, 3, 2, 4][-1076591092, 1, 2, 4, 3]之后的下一个排列,根据definition .

关于c++ - next_permutation 问题 c++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4916175/

相关文章:

string - 查找具有重复字母的单词(排列)的排名

algorithm - 具有重复字符的字符串排列

c++ - QString拆分返回空字符串列表

c++ - 将 BSTR 转换为 CString 时出错

c++ - 基于 wchar_t* 的 vector 的奇怪行为

c++ - 当 min 被定义为宏时如何调用 std::min()?

C++ next_permutation 没有以相反的顺序列出

vector 的 C# memcpy 等效项 (C# List<T>)(语法糖)

c++ - OpenGL - 纹理未显示在整个定义区域

c++ - 对 vector 的 vector 进行排序