洛谷P1706 全排列问题

题目详细链接:https://www.luogu.com.cn/problem/P1706;

没有别的技巧,用STL直接全排列输出即可;

代码如下

#include<bits/stdc++.h>
using namespace std;
int n;
int a[10];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        a[i]=i+1;
    }
    do
    {
        for(int i=0;i<n;i++)
        printf("%5d",a[i]);
        cout<<endl;
    }while(next_permutation(a,a+n));
    return 0;
    
}

 

posted @ 2022-02-04 02:15  江上舟摇  阅读(53)  评论(0编辑  收藏  举报