forked from wotjd4305/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswe1221.java
More file actions
116 lines (89 loc) · 2.59 KB
/
swe1221.java
File metadata and controls
116 lines (89 loc) · 2.59 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import java.util.*;
public class swe1221 {
static Scanner sc = new Scanner(System.in);
static String[] answer;
public static void main(String[] args) {
sc.nextInt();
for(int T=1; T<=10; T++) {
HashMap<String, Integer> map = new HashMap<>();
sc.next();
int N = sc.nextInt();
//입력
MapInput(map, N);
/*
//출력
while (it.hasNext()) {
answer[index++] = (String) it.next();
}
*/
//출력
System.out.println("#" + T);
MapOutput(map);
}
}
public static List sortByValue(HashMap map)
{
List<Integer> list = new ArrayList<>();
list.addAll(map.keySet());
Collections.sort(list, new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
return o1.compareTo(o2);
}
});
return list;
}
public static void MapOutput(HashMap<String, Integer> map)
{
int M;
String buffer;
buffer = "ZRO";
M = map.get(buffer);
for(int i=0; i<M; i++)
System.out.print(buffer +" ");
buffer = "ONE";
M = map.get(buffer);
for(int i=0; i<M; i++)
System.out.print(buffer +" ");
buffer = "TWO";
M = map.get(buffer);
for(int i=0; i<M; i++)
System.out.print(buffer +" ");
buffer = "THR";
M = map.get(buffer);
for(int i=0; i<M; i++)
System.out.print(buffer +" ");
buffer = "FOR";
M = map.get(buffer);
for(int i=0; i<M; i++)
System.out.print(buffer +" ");
buffer = "FIV";
M = map.get(buffer);
for(int i=0; i<M; i++)
System.out.print(buffer +" ");
buffer = "SIX";
M = map.get(buffer);
for(int i=0; i<M; i++)
System.out.print(buffer +" ");
buffer = "SVN";
M = map.get(buffer);
for(int i=0; i<M; i++)
System.out.print(buffer +" ");
buffer = "EGT";
M = map.get(buffer);
for(int i=0; i<M; i++)
System.out.print(buffer +" ");
buffer = "NIN";
M = map.get(buffer);
for(int i=0; i<M; i++)
System.out.print(buffer +" ");
}
public static void MapInput(HashMap<String, Integer> map, int N)
{
for(int i=0; i<N; i++)
{
String buffer = sc.next();
map.put(buffer,map.getOrDefault(buffer,0) +1);
}
}
}