PAT b 1043. Output patest Java version __pat

Source: Internet
Author: User

Given a string of only English letters with a length of not more than 10000. Please reorder the characters and press "Patestpatest ..." to output in order and ignore other characters. Of course, the number of six characters is not necessarily the same, if a certain character has been output, the remaining characters are still printed in the order of Patest until all characters are output.

Input Format:

Enter a non-empty string of only English letters that is not more than 10000 in length on one line.

output Format:

The sorted string is printed on a single line, as required by the topic. The topic guarantees that the output is not empty.

Input Sample:

Redlespaybestpattopteephpereatitappt

Output Sample:

Patestpatestptetptepepee
Import java.util.ArrayList;
Import java.util.List;

Import Java.util.Scanner;
		public class Main {public static void main (string[] args) {Scanner in = new Scanner (system.in);
		String string = In.nextline ();

		In.close ();
		list<character> plist = new arraylist<> ();
		List<character> alist = new arraylist<> ();
		list<character> tlist = new arraylist<> ();
		List<character> elist = new arraylist<> ();
		list<character> slist = new arraylist<> ();

		list<character> tlist = new arraylist<> (); for (int i = 0; i < string.length (); i++) {switch (String.charat (i)) {case ' P ': Plist.add (String.charat (i))
				;
			Break
				Case ' A ': Alist.add (String.charat (i));
			Break
				Case ' T ': Tlist.add (String.charat (i));
			Break
				Case ' E ': Elist.add (String.charat (i));
			Break
				Case ' s ': Slist.add (String.charat (i));
			Break
				Case ' t ': Tlist.add (String.charat (i));

			Break
}		int maxSize = Plist.size ();
		if (Alist.size () > maxSize) {maxSize = Alist.size ();
		} if (Tlist.size () > maxSize) {maxSize = Tlist.size ();
		} if (Elist.size () > maxSize) {maxSize = Elist.size ();
		} if (Slist.size () > maxSize) {maxSize = Slist.size ();
		} if (Tlist.size () > maxSize) {maxSize = Tlist.size ();
			for (int i = 0; i < maxSize i++) {if (I < plist.size ()) {System.out.print (Plist.get (i));
			The IF (I < alist.size ()) {System.out.print (Alist.get (i));
			The IF (I < tlist.size ()) {System.out.print (Tlist.get (i));
			The IF (I < elist.size ()) {System.out.print (Elist.get (i));
			The IF (I < slist.size ()) {System.out.print (Slist.get (i));
			The IF (I < tlist.size ()) {System.out.print (Tlist.get (i));
 }
		}
	}

}

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.