-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10997.cpp
More file actions
55 lines (44 loc) · 1.11 KB
/
10997.cpp
File metadata and controls
55 lines (44 loc) · 1.11 KB
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
#include <iostream>
using namespace std;
char arr[400][400];
void draw(int n, int x, int y){
for(int i = 1; i < 4 * n - 3; i++) arr[x][y--] = '*';
for(int i = 1; i < 4 * n - 1; i++) arr[x++][y] = '*';
for(int i = 1; i < 4 * n - 3; i++) arr[x][y++] = '*';
for(int i = 1; i < 4 * n - 3; i++) arr[x--][y] = '*';
arr[x][y--] = '*';
arr[x][y] = '*';
if(n == 2){
arr[x][y - 1] = '*';
arr[x + 1][y - 1] = '*';
arr[x + 2][y - 1] = '*';
return;
}
draw(n - 1, x, y - 1);
}
int main(){
int n;
cin >> n;
if(n == 1){
cout << "*";
}
else{
for(int i = 0; i < 4 * n - 1; i++){
for(int j = 0; j < 4 * n - 3; j++){
arr[i][j] = ' ';
}
}
draw(n, 0, 4 * n - 4);
for(int i = 0; i < 4 * n - 1; i++){
if(i == 1){
cout << "*" << endl;
continue;
}
for(int j = 0; j < 4 * n - 3; j++){
cout << arr[i][j];
}
cout << endl;
}
}
return 0;
}