#include <bits/stdc++.h>
using namespace std;
char board[2500][2500];
void star(int x,int y,int n) {
    if(n==1) {
        board[x][y]='*';
        return;
    }
    for(int i=0; i<3; i++) {
        for(int j=0; j<3; j++) {
            if(i==1 && j==1) continue;
            
            star(x+i*n/3,y+j*n/3,n/3);
        }
    }
}

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]+n,' ');
    star(0,0,n);
    for(int i=0; i<n; i++) {
        cout << board[i] << '\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: