全排列函数 next_permutation()
2014-03-19 20:33
344 查看
#include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> #include<queue> #include<iostream> #include<algorithm> using namespace std ; int main() { int n,i; int a[100]; while(~scanf("%d",&n)) { for( i = 0 ; i < n ; i++) a[i]=i+1; sort(a, a + n); printf("%d",a[0]); for( i = 1 ; i < n ; i++) printf(" %d",a[i]); printf("\n"); while (next_permutation(a, a + n)) { printf("%d",a[0]); for( i = 1 ; i < n ; i++) printf(" %d",a[i]); printf("\n"); } } return 0; }
相关文章推荐
- Android 系统应用Setting开发小结
- poj Wireless Network(基础并查集)
- Xcode编译异常 Apple Mach-o Linker Error ld: symbol(s) not found for architecture i386
- 华为2014年机试样题 求最大递增数
- windows如何查看端口占用情况
- 第二周作业-程序编写
- 跨进程访问(AIDL服务)—Service(三)
- 敏捷软件方法综述
- HDU 2844 Coins(多重背包)
- Android 利用 Webservice 获取手机号码归属地
- 使用PHP代码对Mysql数据库的数据表显示实例代码
- shell中的${},##和%%的使用
- 图像处理程序,在状态栏显示图像尺寸
- shell中的${},##和%%的使用
- WINCLASS类简介
- javascript中跨源资源共享
- JAVA中的集合
- ndk bug汇总
- Chapter 3 | Stacks and Queues--栈解决汉诺塔问题
- 资料阅读