4495. Print permutations
来源:互联网 发布:windows loader v2.4 编辑:程序博客网 时间:2024/06/05 20:49
4495. Print permutations
Description
A permutation is a possible ordering of a set. For example, the permutations of a set {A,B,C} include ABC, ACB, BAC, BCA, CAB, CBA.
The number of permutations of a set of N elements is N!. The example set above has 3 elements and it has a number of 3!=6 permutations.
Given a line with N different upper letters, please print N! lines containing all different permutations of the N letters. These N! lines are printed in dictionary order.
Input
A line with N (1<=N<=8) different upper letters given in dictionary order.
Output
N! lines containing all different permutations of the N letters. These N! lines are printed in dictionary order.
Sample Input
ABCD
Sample Output
ABCDABDCACBDACDBADBCADCBBACDBADCBCADBCDABDACBDCACABDCADBCBADCBDACDABCDBADABCDACBDBACDBCADCABDCBA
#include <iostream>#include <string>#include <algorithm>using namespace std;int main(){ string a; getline(cin,a); int len=a.length(); int b[8]; for(int i=0;i<len;i++) b[i]=a[i]-'0'; do{for(int i = 0; i < len; i++){cout << char(b[i]+'0'); }cout <<endl;} while (next_permutation(b, b + len));return 0;}
- 4495. Print permutations
- Sicily 4495. Print permutations
- Sicily 4495. Print permutations
- Sicily 4495 Print permutations解题报告
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- Permutations
- 128*64点阵图形液晶显示屏程序设计教程
- 基于visual c++之windows核心编程代码分析(9)实现Windows服务并安装,控制
- centos 下无法进行有线上网的解决方法
- 连连看 代码的实现
- 华南理工大学研究生人工智能期末考试题纲整理文档
- 4495. Print permutations
- 马克•安德森:软件正在占领全世界
- Unable to start service Intent not found 错误
- Linux下C语言连接MySQL找不到mysql.h解决办法
- extern "C"
- .mod.c是什么文件,及内核模块Makefile模板
- 12月16日总结
- 学会进步
- Domino的Ldap服务与使用