#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define sz size() #define pb push_back #define mp make_pair #define fi first #define se second #define along long(c) (c).begin(), (c).end() #define rep(i,a,b) for(ll i=(a);i<(b);++i) #define clr(a, b) memset((a), (b) ,sizeof(a)) #define ctos(d) string(1,d) #define print(x) cout<<#x<<" = "<> n; clr(d, -1); rep(y, 0, n) { rep(x, 0, n) { d[y + 1][x + 1] = 0; } } int dy[4] = {0, 1, 0, -1}; int dx[4] = {1, 0, -1, 0}; int py = 1; int px = 1; int dd = 0; rep(i, 1, n * n+1) { d[py][px] = i; if (d[py + dy[dd]][px + dx[dd]] != 0) { dd++; dd %= 4; } py += dy[dd]; px += dx[dd]; } rep(y,0,n){ rep(x,0,n){ printf("%03d", d[y+1][x+1]); if(x!=n-1)cout << " "; } cout << endl; } return 0; }