using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; using System.Linq; class Magatro { static long N = long.Parse(Console.ReadLine()); static void Main() { int[,] masu = new int[N, N]; //左=0 int muki = 0; int x = 0, y = 0; for(int i = 0; i < N * N; i++) { masu[x, y] = i + 1; switch (muki) { case 0: if (x + 1 < N ) { if (masu[x + 1, y] == 0) { x++; break; } } muki++; y++; break; case 1: if (y + 1 < N ) { if (masu[x, y + 1] == 0) { y++; break; } } muki++; x--; break; case 2: if (x - 1 >= 0 ) { if (masu[x - 1, y] == 0) { x--; break; } } muki++; y--; break; case 3: if (y - 1 >= 0) { if (masu[x , y-1] == 0) { y--; break; } } muki=0; x++; break; } } for(int i = 0; i < N; i++) { string s = ""; for(int j = 0; j < N; j++) { if (j == N - 1) { s+= string.Format("{0:D3}", masu[j, i]); } else { s += string.Format("{0:D3}", masu[j, i])+" "; } } Console.WriteLine(s); } } }