using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace YukiCoder { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int[,] pa = new int[N, N]; int x = 0; int y = 0; int n = 1; pa[0, 0] = n++; while (n < N * N +1) { while (x + 1 < N && pa[y, x + 1] == 0) pa[y, ++x] = n++; while (y + 1 < N && pa[y + 1, x] == 0) pa[++y, x] = n++; while (x - 1 >=0 && pa[y, x - 1] == 0) pa[y, --x] = n++; while (pa[y - 1, x] == 0) pa[--y, x] = n++; } for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) Console.Write(pa[i, j].ToString("D3") + " "); Console.WriteLine(); } //Console.WriteLine(); Console.ReadLine(); } } }