🔻PS/Baekjoon

[Baekjoon] 백준 23794 골뱅이 찍기 - 정사각형 C++

_니지 2022. 10. 7. 16:01

https://www.acmicpc.net/problem/23794

 

23794번: 골뱅이 찍기 - 정사각형

첫째 줄부터 $N+2$번째 줄까지 차례대로 골뱅이를 출력한다.

www.acmicpc.net

 

문제

첫째 줄과 N+2번째 줄에는 골뱅이 N+2개를 출력한다.

둘째 줄부터 N+1번째 줄까지는 예제 출력과 같은 방식으로 골뱅이 2개와 공백 N개를 출력한다.

입력

첫째 줄에 정수 N(1≤N≤100)이 주어진다.

출력

첫째 줄부터 N+2번째 줄까지 차례대로 골뱅이를 출력한다.

예제 입력 1 

1

예제 출력 1 

@@@
@ @
@@@

예제 입력 2 

3

예제 출력 2 

@@@@@
@   @
@   @
@   @
@@@@@

 

코드

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
using namespace std;
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cmath>
#include <map>
#include <set>
#define _CRT_SECURE_NO_WARNINGS
#define INF 987654321
#define ll long long
typedef pair<intint> PII;
 
 
int main() {
    int n;
    cin >> n;
 
    int N = n + 2;
 
 
 
    for (int i = 0; i < N; i++) {
        printf("@");
    }
    printf("\n");
 
 
    for (int i = 0; i < n; i++) {
        printf("@");
 
        for (int j = 0; j < n; j++) {
            printf(" ");
        }
        printf("@");
        printf("\n");
    }
 
 
 
    for (int i = 0; i < N; i++) {
        printf("@");
    }
    printf("\n");
 
 
 
 
    return 0;
}
cs
728x90
반응형