#P5731. Spiral Snake Matrix

    ID: 18959 Type: Default 1000ms 256MiB

Spiral Snake Matrix

Spiral Snake Matrix

Given a positive integer \(n\) (\(1 \le n \le 9\)), you are to generate a \(n \times n\) spiral snake matrix. The matrix should be filled by placing numbers starting from \(1\) from the top-left corner, moving in a clockwise spiral. Each number must be printed in a field width of 3 characters (pad with leading spaces if needed).

Example:

Input:
3

Output: 1 2 3 8 9 4 7 6 5

</p>

inputFormat

The input consists of a single integer \(n\) (\(1 \le n \le 9\)).

n

outputFormat

Output the \(n \times n\) spiral snake matrix. Each number must be printed in a field of width 3 characters. Each row of the matrix is printed on a new line.

sample

1
  1

</p>