#K53962. Spiral Matrix Generation
Spiral Matrix Generation
Spiral Matrix Generation
Given a positive odd integer \(n\), generate an \(n \times n\) spiral matrix with consecutive integers starting from 1. The spiral should be formed by filling the outer layer first and then proceeding inwards in a clockwise direction.
If \(n\) is even, output the error message: "The input must be an odd integer".
For example, when \(n=3\), the output should be:
1 2 3 8 9 4 7 6 5
And when \(n=5\), the output should be:
1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
inputFormat
The input consists of a single integer \(n\) provided via standard input (stdin). \(n\) is expected to be a positive odd integer.
outputFormat
If \(n\) is an odd integer, output the resulting spiral matrix via standard output (stdout) where each row is printed on a new line and numbers are separated by a space. If \(n\) is even, output the message: "The input must be an odd integer".
## sample1
1