본문 바로가기
알고리즘/문자와 문자열

검은 점 세기 더블릿

by tryotto 2019. 2. 28.
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
#include <stdio.h>
 
int arr[200][200= { 0 };
 
int main() {
    int n;
    scanf("%d"&n);
 
    char order[10];
    int x, y, len;
    while (n--) {
        scanf("%s %d %d %d", order, &x, &y, &len);
        if (order[0== 'B') {
            for (int i = y; i < y + len; i++) {
                for (int j = x; j < x + len; j++) {
                    arr[i][j] = 1;
                }
            }
        }
        else if (order[0== 'W') {
            for (int i = y; i < y + len; i++) {
                for (int j = x; j < x + len; j++) {
                    arr[i][j] = 0;
                }
            }
        }
        else if (order[0== 'T') {
            int tmp = 0;
            for (int i = y; i < y + len; i++) {
                for (int j = x; j < x + len; j++) {
                    if (arr[i][j] == 1)
                        tmp++;
                }
            }
            printf("%d\n", tmp);
        }
    }
}
cs


'알고리즘 > 문자와 문자열' 카테고리의 다른 글

2908 상수  (0) 2020.01.04
1157 단어공부  (0) 2020.01.03
11654 아스키 코드  (0) 2020.01.03
blurred vision 더블릿  (0) 2019.03.01
world cup 더블릿  (0) 2019.02.28