-
Notifications
You must be signed in to change notification settings - Fork 7
/
Main.java
85 lines (75 loc) · 1.72 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package basicLevel1043;
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));
}
if (i < AList.size()) {
System.out.print(AList.get(i));
}
if (i < TList.size()) {
System.out.print(TList.get(i));
}
if (i < eList.size()) {
System.out.print(eList.get(i));
}
if (i < sList.size()) {
System.out.print(sList.get(i));
}
if (i < tList.size()) {
System.out.print(tList.get(i));
}
}
}
}