擅长排列的小明
2015-10-06 11:07
260 查看
题目传送门:点击打开链接
//stl里面的next_permutation函数的运用
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;
char b[10], c[10];
int main() {
int t;
cin >> t;
while (t --) {
char a[10] = {'1','2','3','4','5','6','7','8','9','\n'};
memset(b, 0, sizeof(b));
memset(c, 0, sizeof(c));
int n, m;
cin >> n>> m;
strcpy(b, a);
b[m] = '\0';
cout << b<< endl;
while (next_permutation(a, a+n)) {
strcpy(c, a);
c[m] = '\0';
if (strcmp(b, c)) {
strcpy(b, c);
b[m] = '\0';
cout << b<< endl;
}
}
}
return 0 ;
}
//stl里面的next_permutation函数的运用
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;
char b[10], c[10];
int main() {
int t;
cin >> t;
while (t --) {
char a[10] = {'1','2','3','4','5','6','7','8','9','\n'};
memset(b, 0, sizeof(b));
memset(c, 0, sizeof(c));
int n, m;
cin >> n>> m;
strcpy(b, a);
b[m] = '\0';
cout << b<< endl;
while (next_permutation(a, a+n)) {
strcpy(c, a);
c[m] = '\0';
if (strcmp(b, c)) {
strcpy(b, c);
b[m] = '\0';
cout << b<< endl;
}
}
}
return 0 ;
}
相关文章推荐
- Linux文件管理之压缩解压缩
- Python笔记--除法
- 擅长排列的小明
- 创建一个二维数组,求路线,使得和最小
- HDU 1029 Ignatius and the Princess IV
- 弱校联萌十一大决战之厉兵秣马H. Hanoi Towers poj3572
- C语言-蜗牛爬墙
- 解决svn的working copy locked并且cleanup恢复不能的情况
- iOS静态库小结--(yoowei)
- JS实现的文字与图片定时切换效果代码
- Halcon学习笔记_04:划痕、油污、瑕疵
- UML学习笔记
- 重大新闻:借贷宝不用绑卡了,借贷宝APP推出肖像识别新功能!
- 机器学习(二)无监督学习
- 安卓6.0的特性
- CreateWindowEx函数
- 白板编程浅谈——Why, What, How
- 新的一天
- 记录有用的技术博客或网站
- Activity四种启动模式