讲暴力枚举或深搜时会讲到 《全排列问题》。其原理是深搜。 那么如何自己实现一个next_permutation呢·? 一、深搜 代码就不贴了,比较基础。 二、指针 我们可以用指针快速实现: #include <algorithm> #include <iostream> using namespace std; int a[10005]; template <class T> bool _next_permutation(T first, T last) { if