Title Description:
Reads a string of letters (no more than 30 characters) from the keyboard.
Remove 3 non-repeating characters from the string and ask for all the extraction.
The characters that are removed require a string in ascending alphabetical order.
Different output sequences can be used without consideration.
For example:
Input:
Abc
The output:
Abc
Input:
Abcd
The output:
Abc
Abd
Acd
Bcd
Input:
Abcaa
The output:
Abc
Package Ccf;import Java.util.arraylist;import Java.util.hashset;import java.util.linkedhashset;import Java.util.list;import Java.util.scanner;import Java.util.set;public class Getthree_nnorepeat_from_string {public static void Main (string[] args) {Scanner s=new Scanner (system.in); String string = S.next ();p rintabc (Getcharset (String));} public static set<character> Getcharset (String s) {//Because the set collection is non-repeatable and the linedhashset is stored orderly//here is to ensure ordering of the order of additions: for example, A, B, c The resulting set is [a,b,c]. If the use of hashset results for [b,a,c] can not guarantee the storage of ordered set<character> charset=new linkedhashset<character> (); for (int i=0;i<s.length (); i++) {Charset.add (S.charat (i)),//Converts a string into a character into a set set, and the set set does not contain duplicates}system.out.println ( CharSet); return charSet;} public static void Printabc (Set<character> charSet) {//Because the set set is unordered, the set set is converted to listlist<character> list= New Arraylist<character> (CharSet); for (int i = 0, I < list.size ()-2; i++) {for (int j = i + 1; J < ; List.size ()-1; J + +) {for (int k = j + 1; k <List.size (); k++) {System.out.print (List.get (i)); System.out.print (List.get (j)); System.out.print (List.get (k)); System.out.println (); } } }}}
Operation Result:
Abcdabcd
[A, B, C, d]
Abc
Abd
Acd
Bcd
Blue Bridge Cup. Take characters (remove duplicates using the Set list implementation)