#include <bits/stdc++.h>
using namespace std;
char board[3100][6500];
//xy를 좌표 말고 행열로 생각하기 !!!!!!!!!!!!!!!!!!
void star(int x,int y,int n) {
    if(n==3) {
        //젤위
        board[x][y]='*';
        //중간
        board[x+1][y+1]='*';
        board[x+1][y-1]='*';
        //맨 밑
        for(int i=y-2; i<=y+2; i++) {
            board[x+2][i]='*';
        }
        return;
    }
    int ns=n/2;
    star(x,y,ns);
    star(x+ns,y+ns,ns);
    star(x+ns,y-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;
    
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: