【发布时间】:2017-05-12 01:28:37
【问题描述】:
我想知道是否有一种简单的方法可以从 c++ 的std::next_permutation 创建的排列顺序中了解它们的排列的parity(签名)。
int main()
{
int counter = 0;
std::vector<int> mask {0, 1, 2, 3, 4};
do
{
counter++;
// then determine the parity of permutation from knowledge of the counter
} while (std::next_permutation(mask.begin(), mask.end()));
}
或者,是否有内置函数来确定排列的奇偶性?
【问题讨论】:
-
“排列的奇偶性(签名)”是什么意思?能举个例子吗?
标签: c++ std permutation