#P5731. 【深基5.习6】蛇形方阵

【深基5.习6】蛇形方阵

Description

Given a positive integer nn not greater than 99, output an n×nn \times n spiral matrix.

Start by filling 11 in the top-left corner, then fill the numbers in clockwise order, as shown in the sample. Note that each number takes up 33 characters, padded with leading spaces.

Input Format

Input one positive integer nn, with the meaning described above.

Output Format

Output the spiral matrix that meets the requirements.

4
  1  2  3  4
 12 13 14  5
 11 16 15  6
 10  9  8  7

Hint

Constraints: 1n91 \leq n \leq 9.

Translated by ChatGPT 5