본문 바로가기
Computer Science

A기실 암호문1/ 리스트를 배열로

by OKOK 2018. 12. 14.

1. 리스트 문제인데 단순하게 배열로 풀이

2. 왜 근데 44까지만 사용하는 것임?

3. 상관 없음

4. 삽입만 하는 것이므로 10개만 가지고 있어도 되지 않을까? 

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
#include <stdio.h>
int CodeN;
int InstN;
int codeA[44];
int instA[44];
 
int main()
{
    freopen("input.txt""r", stdin);
    int t;
    int i, j, k;
 
    char ins;
    int x, y;
    int s;
 
    for (t = 1; t <= 10; t++)
    {
        for (i = 0; i < 44; i++)
        {
            codeA[i] = 0;
            instA[i] = 0;
        }
        scanf("%d"&CodeN);
        for (i = 0; i < CodeN; i++)
        {
            scanf("%d"&codeA[i]);
        }
        scanf("%d"&InstN);
        for (i = 0; i < InstN; i++)
        {
            scanf(" %c %d %d"&ins, &x, &y);
            x--;
            for (j = 0; j < y; j++)
            {
                scanf("%d"&s);
 
                if (x >= 10continue;
 
                for (k = CodeN - 1; k > x; k--)
                {
                    codeA[k + 1= codeA[k];
                }
                codeA[x + 1= s;
                x++;
            }
        }
        printf("#%d ", t);
 
        for (i = 0; i < 10; i++)
        {
            printf("%d ", codeA[i]);
        }
        printf("\n");
    }
    return 0;
}
 
cs


댓글