#K78247. Spiral Matrix Generator
Spiral Matrix Generator
Spiral Matrix Generator
Given an integer \( N \) (where \( 1 \leq N \leq 100 \)), your task is to generate an \( N \times N \) matrix filled with the integers from 1 to \( N^2 \) in a spiral order. The spiral starts at the top-left corner and moves to the right initially.
For example, when \( N = 3 \), the output should be:
1 2 3 8 9 4 7 6 5
If the given \( N \) is less than or equal to 0, output nothing.
inputFormat
The input consists of a single integer \( N \) on the first line representing the size of the matrix.
outputFormat
Output the \( N \times N \) spiral matrix. Each row should be printed on a separate line with the numbers separated by a single space. If \( N \le 0 \), output nothing.
## sample1
1
</p>