Spirals

Your task is to write a program that prints “spirals” of size n×nn \times n, as it is shown in the examples.

Input

The input consists of a sequence of natural numbers ended with zero.

Output

For each nn, your program must print a spiral of size n×nn \times n. Notice that in the row of the bottom and the column on the rigth there only are |’X’|s. Print a line in white after each spiral.

Observation

Although it is not essential use a matrix to solve this problem, do it for simplicity.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:32:33.095Z

© Jutge.org, 2006–2026.
https://jutge.org