南阳 oj 擅长排列的小明 题目19
2015-07-31 08:16
363 查看
next 以及pre 函数的用法
/article/3583994.html
next 以及pre 函数的用法
/article/3583994.html
#include <stdio.h> #include <string.h> #include <algorithm> char a[10]={'1','2','3','4','5','6','7','8','9','\0'};//给定一个已排列的数组 using namespace std; int main() { int t,n,m; char b[10],c[10],c1[10]; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&m); strcpy(c,a); c[m]='\0'; printf("%s\n",c); while(next_permutation(a,a+n))//将a[0]到a 全排列 从小到大 { strcpy(c1,a); c1[m]='\0';//取前m个元素 if(strcmp(c1,c)!=0) { printf("%s\n",c1); strcpy(c,c1); } } } return 0; }
相关文章推荐
- Grouping Sets:CUBE和ROLLUP从句
- 完美网络(优先队列)
- 多校3-Magician
- 多校3-Magician 分类: 比赛 2015-07-31 08:13 4人阅读 评论(0) 收藏
- 二分查找
- 天才的大三暑假修行之旅.再遇打飞机
- c-ares 一个C语言的异步DNS解析库
- 编程选择,多线程or多进程?
- STL具体操作之next_permutation和prev_permutation函数
- java工具类(一)之服务端java实现根据地址从百度API获取经纬度
- python模块学习
- java工具类(一)之服务端java实现根据地址从百度API获取经纬度
- 直接拿来用!十大Material Design开源项目
- 手动打开optionmenu的方法
- 《关于多代理系统的研究》03
- [转载] 读《UNIX网络编程 卷1:套接字联网API》
- MBEWH-查看历史期间的移动平均价
- Eclipse里项目名有红叉,但是底下的每一个文件都没有红叉
- 【项目总结】:如何做一个牛逼的Team leader?
- android Intent机制详解