Full sequence of Java dictionaries

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.