-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2447.cpp
More file actions
53 lines (46 loc) · 789 Bytes
/
2447.cpp
File metadata and controls
53 lines (46 loc) · 789 Bytes
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
// 2447. 별 찍기 - 10
// 2019.05.20
// 별 찍기
#include<iostream>
using namespace std;
char map[2201][2201];
void MakeStar(int x, int y, int num)
{
if (num == 1)
{
map[x][y] = '*';
return;
}
int div = num / 3;
// 자기 자신을 제외한 인접한 8방향
MakeStar(x, y, div);
MakeStar(x, y + div, div);
MakeStar(x, y + div * 2, div);
MakeStar(x + div, y, div);
MakeStar(x + div, y + div * 2, div);
MakeStar(x + div * 2, y, div);
MakeStar(x + div * 2, y + div, div);
MakeStar(x + div * 2, y + div * 2, div);
}
int main()
{
int n;
cin >> n;
MakeStar(0, 0, n);
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
if (map[i][j] == '*')
{
cout << map[i][j];
}
else
{
cout << " ";
}
}
cout << "\n";
}
return 0;
}