본문 바로가기
Programming/Algorithm

swe 1221 GNS

by OKOK 2018. 3. 30.

1. 문자열 처리하는 방법

2. 인풋이 의미하는바 명확히 할것

3. 설계시 단순한 문제도, 어떻게 하면 더 쉽게 풀 수 있을지, 한번 더 고민할 것

4. 오히려 쉬운데 안풀어본 문제는 자료구조가 쉽게 떠오르지 않음.

5. 단순한 방법말고, 정리된 방법을 어떻게 사용할 수 있을지 고민할 것.


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
/*
1406 문제풀이 시작합니다.
1221 GNS
*/
 
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
 
string tc;
char word[100001];
int k;
int numArr[2500];
int index;
int length;
int numCnt;
string str;
int num[10];
char *str2[10= { "ZRO""ONE""TWO""THR""FOR""FIV""SIX""SVN""EGT""NIN" };
 
void problemIn() {
    cin >> tc;
    cin >> k;
    for (int i = 0; i < k; i++) {
        cin >> str;
        if (str == "ZRO") num[0]++;
        else if (str == "ONE") num[1]++;
        else if (str == "TWO") num[2]++;
        else if (str == "THR") num[3]++;
        else if (str == "FOR") num[4]++;
        else if (str == "FIV") num[5]++;
        else if (str == "SIX") num[6]++;
        else if (str == "SVN") num[7]++;
        else if (str == "EGT") num[8]++;
        else if (str == "NIN") num[9]++;
    }
}
 
void solve() {
 
    cout << tc << endl;
    
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < num[i]; j++) {
            cout << str2[i] << " ";
        }
        num[i] = 0;
    }
    cout << endl;
}
 
int main() {
    int T;
    cin >> T;
    for (int i = 0; i < 10; i++) {
        problemIn();
        solve();
    }
    return 0;
}
cs