Description of STL implementation for a fully arranged algorithm:
-
Given a string composed of different lower-case letters, all the strings are output in full order.
Assume that lowercase letters include 'A' <'B' <... <'y' <'Z', and the letters in the given string are arranged in ascending order.
-
Input:
-
The input contains only one row, which is a string consisting of different lower-case letters. It is known that the length of the string is between 1 and 6.
-
Output:
-
Output all the sorting methods of this string, one in each line. A relatively small alphabetic order is required to be arranged in front. The alphabetical order is defined as follows:
If S = s1s2... sk, T = t1t2... tk is known, S <T is equivalent to p (1 <= p <= k ),
S1 = t1, s2 = t2,..., sp-1 = tp-1, sp <tp is true.
-
Sample input:
-
abc
-
Sample output:
-
abcacbbacbcacabcba
-
Tip:
-
After the output of each sample is complete, a carriage return is output.
AC code:
#include
#include
#includeusing namespace std;int main(int argc,char *argv[]){char letters[10];while(scanf("%s",letters)!=EOF){printf("%s\n",letters);while(next_permutation(letters,letters+strlen(letters)))printf("%s\n",letters);printf("\n");}return 0;}
If cin is used, cout times out... STL is simple to solve this problem !!!