#include #include #include using namespace std; vector dy = {0, 1, 0, -1}; vector dx = {1, 0, -1, 0}; int main(){ int N; cin >> N; vector> ans(N + 2, vector(N + 2, "#")); for (int i = 1; i <= N; i++){ for (int j = 1; j <= N; j++){ ans[i][j] = "."; } } int y = 1; int x = 1; int d = 0; for (int i = 1; i <= N * N; i++){ string S = to_string(i); while (S.size() < 3){ S = '0' + S; } if (ans[y + dy[d]][x + dx[d]] != "."){ d++; if (d == 4){ d = 0; } } y += dy[d]; x += dx[d]; ans[y][x] = S; } for (int i = 1; i <= N; i++){ for (int j = 1; j <= N; j++){ cout << ans[i][j]; if (j < N){ cout << ' '; } } cout << endl; } }