#include <bits/stdc++.h>
using namespace std;

void star(int x, int y, int n){
    if((x/n)%3==1 && (y/n)%3==1) cout <<' ';
    else {
        if(n/3==0) cout << '*';
        else {
            star(x,y,n/3);
        }
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            star(i,j,n);
        }
        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: