#K35542. Spiral Matrix Generation

    ID: 25554 Type: Default 1000ms 256MiB

Spiral Matrix Generation

Spiral Matrix Generation

Given a positive integer n, generate an n x n spiral matrix filled with the integers from 1 to \(n^2\) in spiral order. The spiral order is defined as starting from the top-left corner, moving to the right, then down, then left, and then up, repeating this process until the entire matrix is filled.

For example, when n = 3, the spiral matrix is:

1 2 3
8 9 4
7 6 5

The output should be printed to stdout with each row on a new line and numbers separated by a single space.

inputFormat

The input is read from stdin and consists of a single integer n (1 \(\leq n \leq 100\)).

outputFormat

The output is the generated spiral matrix printed to stdout. Each row of the matrix should appear on a new line with the numbers separated by a single space.

## sample
1
1