4495. Print permutations

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

ABCD
ABDC
ACBD
ACDB
ADBC
ADCB
BACD
BADC
BCAD
BCDA
BDAC
BDCA
CABD
CADB
CBAD
CBDA
CDAB
CDBA
DABC
DACB
DBAC
DBCA
DCAB
DCBA

#include 
#include 
#include 
using namespace std;

int main()
{
    string a;
    getline(cin,a);
    int len=a.length();
    int b[8];
    for(int i=0;i


你可能感兴趣的:(西西里水题(水到爆阿),刷题之旅)