C ++算法的N!订单 [英] C++ algorithm for N! orderings

查看:131
本文介绍了C ++算法的N!订单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个N项列表,我想知道如何循环通过列表来获得每个组合。没有双打,所以我需要得到所有N!订单。额外的内存没有问题,我想想最简单的算法,但我有麻烦。

I have a list of N items and I am wondering how I can loop through the list to get every combination. There are no doubles, so I need to get all N! orderings. Extra memory is no problem, I'm trying to think of the simplest algorithm but I'm having trouble.

推荐答案

a href =http://en.cppreference.com/w/cpp/algorithm/next_permutation =nofollow> std :: next_permutation   

See std::next_permutation   

这篇关于C ++算法的N!订单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆