- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
n = int(input())
matrix = [[0] * n for i in range(n)]
num = 1
end = n
start = 0
while num != num**2:
for i in range(start, end):
if num == num**2:
break
for j in range(start, end):
if num == num**2:
break
matrix[i][j] = num
num += 1
if j + 1 == end:
for k in range(start+1, end):
if num == num**2:
break
matrix[k][j] = num
num += 1
if k + 1 == end:
for l in range(-end+1, -start):
if num == num**2:
break
matrix[k][l] = num
num += 1
if l + 1 == start:
for m in range(-end+1, -start-1):
if num == num**2:
break
matrix[m][l] = num
num += 1
end -= 1
start += 1
for i in range(n):
for j in range(n):
print(matrix[i][j], end='\t')
print()