#P5731. Spiral Snake Matrix
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</p>Output: 1 2 3 8 9 4 7 6 5
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>