본문 바로가기
Computer Science

GNS

by OKOK 2019. 1. 22.

1. NUM 하는 방법

2. buf 한번에 들어오므로 저렇게 처리를 진행함

3. 문자열 입력 받을 때 주의해야 할 점

4. 다른 사람들은 어떻게 풀었는지 확인


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
#include <stdio.h>
#define NUMLEN (10)
 
char NUM[NUMLEN][4= 
{
    "ZRO""ONE""TWO""THR""FOR""FIV""SIX""SVN""EGT""NIN"
};
char buf[10000 + 1];
int T, test;
int cTABLE[NUMLEN];
 
int ATI(char* str) {
    switch (*str) {
    case 'Z'return 0;
    case 'O'return 1;
    case 'E'return 8;
    case 'N'return 9;
    case 'T'
        {
            if (str[1== 'H'return 3;
            else return 2;
        }
    case 'F' : 
        {
            if (str[1== 'I'return 5;
            else return 4;
        }
    case 'S' :
        {
            if (str[1== 'I'return 6;
            else return 7;
        }
        break;
    }
    return -1;
}
 
void input(void
{
    int tCount, count = 0;
    scanf("%*s %d"&tCount);
    while (count < tCount) {
        scanf("%s", buf);
        ++cTABLE[ATI(buf)];
        ++count;
    }
}
 
void output(void
{
    int i;
    printf("#%d\n", test);
    for (i = 0; i < NUMLEN; ++i)
    {
        while (cTABLE[i] > 0)
        {
            --cTABLE[i];
            printf("%s ", NUM[i]);
        }
    }
    puts("");
}
 
int main(void)
{
    freopen("input.txt""r", stdin);
    scanf("%d"&T);
    for (test = 1; test <= T; ++test)
    {
        input();
        output();
    }
    return 0;
}
cs

 


'Computer Science' 카테고리의 다른 글

계산기1  (0) 2019.01.22
magnetic  (0) 2019.01.22
길찾기  (0) 2019.01.21
괄호짝짓기  (0) 2019.01.21
거듭 제곱  (0) 2019.01.21

댓글