#include <bits/stdc++.h>
using namespace std;
char board[3100][6500];
//xy를 좌표 말고 행열로 생각하기 !!!!!!!!!!!!!!!!!!
void star(int row,int col,int n) {
if(n==3) {
//맨위
board[row][col]='*';
//중간
board[row+1][col+1]='*';
board[row+1][col-1]='*';
//맨밑
for(int i=col-2; i<=col+2; i++) {
board[row+2][i]='*';
}
return;
}
int ns=n/2;
star(row,col,ns);
star(row+ns,col-ns,ns);
star(row+ns,col+ns,ns);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
for(int i=0; i<n; i++) fill(board[i],board[i]+2*n,' ');
star(0,n-1,n);
for(int i=0; i<n; i++) {
for(int j=0; j<2*n-1; j++) {
cout << board[i][j];
}
cout <<'\n';
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: