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));

 

posted @ 2017-10-13 21:57  ninding  阅读(338)  评论(0编辑  收藏  举报