Import java.util.arrays;/*** Dictionary full arrangement * string of full array * such as the word "too" its full array is "oot", "Oto", "too" * *, starting from the right side of the scan, if the previous one is smaller than the latter, Record the previous element below the table index*2, and then find the index after the element larger than the minimum value of the subscript, (implementation see below Getmin method) *3,index After the element implementation reversal (Implementation see reverse method below) * End condition: The previous one is larger than the latter. */public Class stringexpress{int getmin (char[]input,int index) {char min=input[index]; int minindex=index+1; Char result= ' z '; for (int i=index+1;i<input.length;i++) {if (Input[i]>min&&input[i]<result) {R Esult=input[i]; Minindex=i; }} return minindex; } void Exchange (char []input,int index,int minindex) {char temp=input[index]; Input[index]=input[minindex]; Input[minindex]=temp; } void Reverse (char input[],int first,int end) {while (first<end) {Exchange (input,first,end); first++; end--; }} void Getdictionary (char c[]) {System.out.println (new String (c)); BooleanFlag=true; int i=0; while (true) {i=c.length-1; for (; i>0;i--) {if (c[i-1]<c[i]) break; } if (i==0) break; int minindex=getmin (C,I-1); Exchange (C,I-1,MININDEX); Reverse (c,i,c.length-1); System.out.println (New String (c)); }} public static void main (string []args) {string input= "AAT"; Char [] C=input.tochararray (); Arrays.sort (c); New Stringexpress (). Getdictionary (c); }}
Full sequence of Java dictionaries