<> Title Description

Given a string of different lowercase letters , Output all permutations of this string .
Let's assume that for lowercase letters there are ’a’ < ‘b’ < … < ‘y’ < ‘z’, And the letters in the given string have been arranged from small to large .

<> input

There is only one line of input , Is a string of different lowercase letters , The length of a known string is 1 reach 6 between .

<> output

Output all permutations of this string , One permutation per line . Require a smaller alphabetic order in front . The alphabetic order is defined as follows :
Known S = s1s2…sk , T = t1t2…tk, be S < T Equivalent to , existence p (1 <= p <= k), bring
s1 = t1, s2 = t2, …, sp - 1 = tp - 1, sp < tp establish .

Note that each sample output is followed by a blank line .

<> sample input
xyz
<> sample output
xyz xzy yxz yzx zxy zyx
<> Tips

use STL In next_permutation It will be very concise .
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring>
using namespace std; int main() { char str[7]; while(scanf("%s",str)!=EOF){ int
len=strlen(str); do{ for(int i=0;i<len;i++) cout <<str[i]; cout <<endl; }while(
next_permutation(str,str+len)); cout <<endl; } return 0; }

Technology
©2019-2020 Toolsou All rights reserved,
It's unexpected Python Cherry tree (turtle The gorgeous style of Library )html Writing about cherry trees , Writing about cherry trees java Four functional interfaces ( a key , simple ) Browser kernel ( understand )06【 Interpretation according to the frame 】 Data range filtering -- awesome HashMap Explain in detail os Simple use of module computer network --- Basic concepts of computer network ( agreement , system ) Some East 14 Pay change 16 salary , Sincerity or routine ?