C++ STL next_permutation() prev_permutation(a,a+n)用法。

int a[3] = {1,2,3};

a可能形成的集合为{1,2,3},{1,3,2},{2,1,3},{2,3,1},{3,1,2},{3,2,1}。

{2,1,3}的prev是{1,3,2},

next是{2,3,1}。

用法

do{
        //do something......

}while(next_permutation(a,a+n));
原文地址:https://www.cnblogs.com/zhangjiuding/p/7663507.html