枚举排列
2016-05-07 19:47
246 查看
/* 利用STL中的next_permutation枚举排列 */ #include <iostream> #include <algorithm> using namespace std; int main() { int n, s[10]; int cnt = 0; //计数共有多少种排列组合 cin >> n; for(int i = 0; i < n; i++) cin >> s[i]; sort(s, s + n); do { for(int i = 0; i < n; i++) cout << s[i] << " " ; cout << endl; cnt++; } while(next_permutation(s, s + n)); cout << cnt << endl; return 0; }
相关文章推荐
- 在ubuntu更新时,出现错误E: Some index files failed to download, they have been ignored, or old ones used inst
- 框架选取以及理由
- ZOJ1003 Crashing Balloon
- java设计模式之结构型模式-装饰模式
- ArchLinux 安装boost库
- 实习感悟
- 2016年linux学习决心书
- 历届试题 最大子阵
- Linux安装Java
- 2016.5.7
- hihocode #1299 打折机票
- 积性函数、线性筛、莫比乌斯反演和一堆乱七八糟的题目
- 学习进度条10
- ML—EM
- LeetCode-55.Jump Game
- java 单例模式(Singleton)
- MAC在Finder栏显示所浏览文件夹路径的方法
- ActionBar
- java.util.concurrent 使用详解
- EmguCV的学习日志(一)