是否可以使用 std::next_permutation() 来排列我创建的类的向量的元素?
next_permutation() 中的比较参数如何工作?
是否可以使用 std::next_permutation() 来排列我创建的类的向量的元素?
Yes!
Try this
#include<iostream>
#include<vector>
#include<algorithm>
int main()
{
typedef std::vector<int> V; //<or_any_class>
V v;
for(int i=1;i<=5;++i)
v.push_back(i*10);
do{
std::cout<<v[0]<<" "<<v[1]<<" "<<v[2]<<" "<<v[3]<<" "<<v[4]<<std::endl;;
}
while(std::next_permutation(v.begin(),v.end()));
}
next_permutation() 中的比较参数如何工作?
This可能有帮助
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)