50919 题解 递归实现排列型枚举

递归实现排列型枚举

https://ac.nowcoder.com/acm/problem/50919

c++ stl全排列函数 next_permutation不香吗qwq

#include<cstdio> 
#include<algorithm>
using namespace std;
int n,a[9]= {1,2,3,4,5,6,7,8,9};
int main() {
    scanf("%d",&n);
    do {
        for (int i=0; i<n; i++) printf("%d ",a[i]);
        puts("");
    } while(next_permutation(a,a+n));
}
全部评论

相关推荐

评论
3
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务