공부하는 히욤이

1221. [S/W 문제해결 기본] 5일차 - GNS 본문

Algorithm/SW Expert Academy

1221. [S/W 문제해결 기본] 5일차 - GNS

히욤이 2019. 3. 5. 22:44

1221. [S/W 문제해결 기본] 5일차 - GNS

문제의 저작권은 SW Expert에 있습니다 


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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
 
public class Solution_1221 {
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int T = Integer.parseInt(br.readLine());
        StringTokenizer st;
 
        for (int test_case = 1; test_case <= T; test_case++) {
            st = new StringTokenizer(br.readLine());
            st.nextToken();
            int num = Integer.parseInt(st.nextToken());
 
            st = new StringTokenizer(br.readLine());
            String[] arr = new String[num];
            for (int i = 0; i < num; i++) {
                arr[i] = st.nextToken();
            }
            int[] res = new int[num];
            
            String[] number = {"ZRO""ONE""TWO""THR""FOR""FIV""SIX""SVN""EGT""NIN"};
            for (int i = 0; i < arr.length; i++) {
                if (arr[i].equals(number[0])) {
                    res[i] = 0;
                } else if (arr[i].equals(number[1])) {
                    res[i] = 1;
                } else if (arr[i].equals(number[2])) {
                    res[i] = 2;
                } else if (arr[i].equals(number[3])) {
                    res[i] = 3;
                } else if (arr[i].equals(number[4])) {
                    res[i] = 4;
                } else if (arr[i].equals(number[5])) {
                    res[i] = 5;
                } else if (arr[i].equals(number[6])) {
                    res[i] = 6;
                } else if (arr[i].equals(number[7])) {
                    res[i] = 7;
                } else if (arr[i].equals(number[8])) {
                    res[i] = 8;
                } else if (arr[i].equals(number[9])) {
                    res[i] = 9;
                }
            }
            
            Arrays.sort(res);
            
            for (int i = 0; i < res.length; i++) {
                if (res[i] == 0) {
                    arr[i] = number[0];
                } else if (res[i] == 1) {
                    arr[i] = number[1];
                } else if (res[i] == 2) {
                    arr[i] = number[2];
                } else if (res[i] == 3) {
                    arr[i] = number[3];
                }else if (res[i] == 4) {
                    arr[i] = number[4];
                }else if (res[i] == 5) {
                    arr[i] = number[5];
                }else if (res[i] == 6) {
                    arr[i] = number[6];
                }else if (res[i] == 7) {
                    arr[i] = number[7];
                }else if (res[i] == 8) {
                    arr[i] = number[8];
                }else if (res[i] == 9) {
                    arr[i] = number[9];
                }
            }
            System.out.print("#"+test_case +" ");
            for (int i = 0; i < arr.length; i++) {
                System.out.print(arr[i] +" ");
            }
            System.out.println();
        }
 
    }
 
}
 
cs


'Algorithm > SW Expert Academy' 카테고리의 다른 글

1226. 미로1  (0) 2019.04.05
4299. 태혁이의 사랑은 타이밍  (5) 2019.03.05
3408. 세가지 합 구하기  (0) 2019.03.05
1928. Base64 Decoder  (0) 2019.03.05
2043. 서랍의 비밀번호  (0) 2019.03.05