#K63412. Spiral Matrix Pattern Generator
Spiral Matrix Pattern Generator
Spiral Matrix Pattern Generator
Given a positive integer \(n\), generate an \(n \times n\) matrix filled with numbers from 1 to \(n^2\) in a spiral order. The spiral traversal starts from the top-left corner, moves right along the top row, then descends the rightmost column, moves left along the bottom row, and finally ascends the leftmost column, continuing in this fashion until the matrix is completely filled.
Each number in the output should be right-aligned with a width of 2 characters. For example, when \(n = 3\), the output should be:
1 2 3 8 9 4 7 6 5
inputFormat
The input is provided from stdin and consists of a single integer \(n\) (where \(1 \leq n \leq 100\)), representing the size of the matrix.
outputFormat
Output the spiral matrix pattern to stdout. Each row of the matrix should be printed on a new line, with each number right-aligned using a width of 2 characters and separated by a single space.
## sample1
1
</p>