#K37742. Spiral Matrix Generator
Spiral Matrix Generator
Spiral Matrix Generator
You are given an integer n ($1 \le n \le 50$). Your task is to generate a spiral matrix of size n×n filled with the integers from 1 to n^2. The filling should start at the top-left corner and proceed in a spiral order (to the right, then down, then left, and then up), until the entire matrix is filled.
For example, for n = 3, the resulting matrix should be:
1 2 3 8 9 4 7 6 5
Make sure your program reads from standard input and writes the result to standard output, where each row of the matrix is on a separate line and the numbers are separated by a space.
inputFormat
The input consists of a single integer n provided via standard input.
Input Format:
n
where n is the size of the matrix.
outputFormat
Output the generated spiral matrix to standard output. Each of the n rows should be printed on a separate line and each row should contain n numbers separated by a single space.
## sample1
1