小编Rag*_*nar的帖子

使用STL列出特定子集

假设我有一个数字范围,比如{2,3,4,5},按顺序存储在a中std::vector v,并且我想列出所有可能的子集,以5结尾使用STL ...即:

2 3 4 5
2 3 5
2 4 5
3 4 5
2 5
3 5
4 5
5
Run Code Online (Sandbox Code Playgroud)

(我希望我不要忘记任何:))

我试过用while(next_permutation(v.begin(),v.end()))但没想出想要的结果:)

有没有人有想法?

PS:那些已经完成谷歌代码堵塞2010年档案的人可能会认识到这一点:)

c++ combinations stl

0
推荐指数
1
解决办法
2174
查看次数

标签 统计

c++ ×1

combinations ×1

stl ×1