D的小L
来源:互联网 发布:怎么升级4g网络 编辑:程序博客网 时间:2024/04/28 04:14
D的小L
时间限制:4000 ms | 内存限制:65535 KB
难度:2
- 描述
- 一天TC的匡匡找ACM的小L玩三国杀,但是这会小L忙着哩,不想和匡匡玩但又怕匡匡生气,这时小L给匡匡出了个题目想难倒匡匡(小L很D吧),有一个数n(0<n<10),写出1到n的全排列,这时匡匡有点囧了,,,聪明的你能帮匡匡解围吗?
- 输入
- 第一行输入一个数N(0<N<10),表示有N组测试数据。后面的N行输入多组输入数据,每组输入数据都是一个整数x(0<x<10)
- 输出
- 按特定顺序输出所有组合。
特定顺序:每一个组合中的值从小到大排列,组合之间按字典序排列。 - 样例输入
223
- 样例输出
1221123132213231312321
在C++的标准函数库STL中,next_permutation()函数用于求数列的全排列。
#include <algorithm>bool next_permutation( iterator start, iterator end );例如:int main () { int myints[] = {1,2,3}; cout << "The 3! possible permutations with 3 elements:\n"; sort (myints,myints+3); do { cout << myints[0] << " " << myints[1] << " " << myints[2] << endl; } while ( next_permutation (myints,myints+3) ); return 0;}
#include<iostream>#include <algorithm>#include<cstring>using namespace std;#include<vector>int main (){ int t; cin>>t; int n; while(t--) { cin>>n; int m[1000]; memset(m,0,sizeof(m)); for(int i=0;i<n;i++) m[i]=i+1; do { for(int i=0;i<n;i++) cout<<m[i]; cout<<endl; } while ( next_permutation (m,m+n) ); } return 0;}
0 0
- D的小L
- d的小l
- D的小L
- D的小L
- D的小L
- D的小L
- D的小L
- D的小L
- D的小L
- D的小L
- D的小 L
- D的小L
- D的小L
- D的小L
- D的小L
- D的小L
- D的小L
- D的小L
- 103. Binary Tree Zigzag Level Order Traversal
- 移动互联网App测试流程及测试点之功能测试
- U盘安装CentOS7.1教程
- 修改连接到的WiFi网络属性,解决手机上网慢的问题
- [kuangbin带你飞]专题五 并查集 A POJ 2236
- D的小L
- iOS开发--适配iOS 10以及Xcode 8
- 漫步华尔街
- ReactiveX文档中文翻译
- vim配置
- Spring定时器的使用(注解+xml形式)
- 八大排序--插入排序
- 【USACO题库】2.2.4 Party Lamps派对灯
- 412. Fizz Buzz