#K88457. Spiral Matrix Generation

    ID: 37312 Type: Default 1000ms 256MiB

Spiral Matrix Generation

Spiral Matrix Generation

Given an integer \( n \), generate an \( n \times n \) matrix filled with consecutive integers from \(1\) to \(n^2\) arranged in a spiral order (clockwise starting from the top-left corner). If \( n \) is non-positive, output nothing.

Each row of the matrix should be displayed on a separate line with the numbers separated by a single space.

inputFormat

The input consists of a single integer \( n \) provided via standard input.

outputFormat

Output the spiral matrix with each row on a new line and numbers separated by a space. If \( n \) is non-positive, do not output anything.

## sample
3
1 2 3

8 9 4 7 6 5

</p>