LSD chain cardinality to sort the numeric bug; list three characters in sequence in a string

Source: Internet
Author: User
Tags addall numeric sort
Import java.util.LinkedList;
Import Java.util.Random; Class num{private int pos1 public int getPos1 () {return pos1;} public void setPos1 (int pos1) {this.pos1 = POS1;} pub LIC int GetPos10 () {return POS10.} public void SetPos10 (int pos10) {this.pos10 = POS10;} public int getPos100 () {Retu
RN pos100; public void setPos100 (int pos100) {this.pos100 = pos100;} public int getPos1000 () {return pos1000;} public void Setp
os1000 (int pos1000) {this.pos1000 = pos1000;} private int pos10;
private int pos100;
private int pos1000;
    
    
public Num (int x) {pos1=x%10; pos10= (x%1000)%100)/10; pos100= (x%1000)/100; pos1000=x/1000; public string toString () {string str= ""; if (pos1000!=0) {str+=pos1000} if (pos100!=0) {str+=pos100;} if (pos10!=0
) {str+=pos10;} str+=pos1;
return str; } public class Lsd_no_position {@SuppressWarnings ("unchecked") static void Lsdsort (Linkedlist<num> lst) {Li
Nkedlist[] Digit=new linkedlist[10]; for (int i = 0; i < Digit.lengtH i++) digit[i]=new LinkedList ()//unclear how many values are inside, with linkedlist load//Assignment while (lst.size () >0) {Num n=lst.remove (); digit[
N.GETPOS1 ()].add (n);
//collect for (int i = 0; i < digit.length i++) Lst.addall (digit[i));
* More wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/programming/sjjg/*/digit=new linkedlist[10]; for (int i = 0; i < digit.length i++) digit[i]=new LinkedList ()//unclear how many values are inside, use LinkedList to load//assign while (Lst.size () >0)
{Num n=lst.remove ();
Num n2=n;
DIGIT[N.GETPOS10 ()].add (n);
    
//collect for (int i = 0; i < digit.length i++) Lst.addall (digit[i));
Digit=new LINKEDLIST[10]; for (int i = 0; i < digit.length i++) digit[i]=new LinkedList ()//unclear how many values are inside, use LinkedList to load//assign while (Lst.size () >0)
{Num n=lst.remove (); int x=n.getpos100 (); digit[n.getpos100 ()].add (n);}
    
    
Collect for (int i = 0; i < digit.length i++) Lst.addall (digit[i));
Digit=new LINKEDLIST[10]; for (int i = 0; i < digit.length i++) digit[i]=new LinkedList ()//unclear how many values there are, use LinkedList to load//assign while (LST.Size () >0) {Num n=lst.remove (); int x1=n.getpos1 (); int x10=n.getpos10 (); int x100=n.getpos100 (); int X1000=N.GETPOS10
    
00 ();
digit[n.getpos1000 ()].add (n);
    
    
//collect for (int i = 0; i < digit.length i++) Lst.addall (digit[i));
public static void Main (string[] args) {//TODO auto-generated method stub Random r=new Random ();
Linkedlist<num> list=new linkedlist<num> (); /* for (int i = 0; i < 5; i++) {List.add (New Num (R.nextint (10000)));}
* * List.add (new Num (2740));
List.add (New Num (6263));
List.add (New Num (5156));
List.add (New Num (623));
    
List.add (New Num (9345));
Lsdsort (list);
SYSTEM.OUT.PRINTLN (list); }
}

The above code with random number put in, the results are not sorted, but instead of the corresponding number of randomly generated to put in, the result is sorted, solve, if resolved, please contact the station

Reads a string composed of letters from the keyboard (no more than 30 characters). Remove 3 distinct characters from the string and ask for all of them. The extracted characters require a string in ascending alphabetical order.

Different output order can not be considered.

For example:

Input:
Abc
The output:
Abc

Input:
Abcd
The output:
Abc
Abd
Acd
Bcd

Input:
Abcaa
The output:
Abc

Import java.util.ArrayList;
Import Java.util.HashSet;
Import Java.util.Iterator;
Import java.util.List;
Import Java.util.Scanner;
Import Java.util.Set; public class Uniquealphasort {/** * @param args */@SuppressWarnings ("unchecked") public static void Main (string[) args)
{Scanner scanner=new Scanner (system.in);
String Str=scanner.nextline ();
Set alphaset=new hashset ();
for (int i = 0; i < str.length (); i++) {Alphaset.add (Str.charat (i));}
List<character> list=new arraylist<character> ();
Iterator Iterator=alphaset.iterator ();  while (Iterator.hasnext ()) {List.add (Character) Iterator.next ());}//Sort for (int i = List.size ()-1; I >0; i--) {for (int j = 0; J < i; J + +)
{if (List.get (j) >list.get (j+1)) {char tmp=list.get (j); List.set (J, List.get (j+1)); List.set (j+1, TMP);}} for (int i = 0; i < list.size ()-2; i++) {for (int j = i+1; J < List.size ()-1; j +) {for (int j2 = j+1; J2 < L Ist.size ();
j2++) {String x=list.get (i). toString (); String X1=liSt.get (j). ToString ();
String X2=list.get (J2). toString ();
System.out.println (X+X1+X2); }
}
}
}
}

Author: csdn Blog u010026901

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.