全排列与next_permutation函数

//以生存1-5全排列为例

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,p[10]={1,2,3,4,5,6,7,8};
    do
    {
        for(int i=0;i<5;i++)
        printf("%d ",p[i]);
        printf("\n");
    }while(next_permutation(p,p+5));
    return 0;
}
 

猜你喜欢

转载自blog.csdn.net/lanshan1111/article/details/81381731