#C1710. Spiral Matrix Generation
Spiral Matrix Generation
Spiral Matrix Generation
Given an integer \(n\), generate an \(n \times n\) spiral matrix filled with numbers from 1 to \(n^2\) arranged in clockwise order starting from the top-left corner. For example, when \(n=3\), the spiral matrix is:
1 2 3 8 9 4 7 6 5
Your task is to read \(n\) from standard input and output the corresponding spiral matrix, with each row printed on a new line and numbers separated by a single space.
inputFormat
The input consists of a single integer \(n\) (\(1 \leq n \leq 100\)).
outputFormat
Output the generated spiral matrix with \(n\) rows. Each row should contain \(n\) space-separated integers.
## sample3
1 2 3
8 9 4
7 6 5
</p>