
搜索
moyangxian
MoYang
展开
-
排列数字(DFS)
题目链接 给定一个整数n,将数字1~n排成一排,将会有很多种排列方法。 现在,请你按照字典序将所有的排列方法输出。 输入格式 共一行,包含一个整数n。 输出格式 按字典序输出所有排列方案,每个方案占一行。 数据范围 1≤n≤7 输入样例: 3 #include<iostream> using namespace std; int a[10]; bool st[10]; int n; ...原创 2020-04-07 21:28:40 · 239 阅读 · 0 评论 -
递归和排列
问题1:打印n个数的全排列(共n!个) 方法一: STL的实现方法(用next_permutation) #include<iostream> #include<algorithm>//包含了sort和next_permutation两个函数 using namespace std; int main(){ int data[4]={1,3,2,4}; ...原创 2020-02-21 18:56:17 · 124 阅读 · 0 评论