STL中的全排列函数next_permutation(转)

https://www.cnblogs.com/My-Sunshine/p/4985366.html

模板

//需要sort一遍
    do
    {
        for (int i=1;i<n;i++)
        {
            printf("%5d",a[i]);
        }
        printf("%5d\n",a[n]);
    }while(next_permutation(a+1,a+n+1));

 

posted @ 2018-07-19 15:51  TheSilverMoon  阅读(160)  评论(0编辑  收藏  举报