#K2376. Diamond Shape Generator

    ID: 24723 Type: Default 1000ms 256MiB

Diamond Shape Generator

Diamond Shape Generator

You are given a task to generate a diamond shape pattern with a given integer n. The diamond is composed of asterisks (*) and spaces. Its structure is symmetric vertically. For a given integer n, the diamond has 2n-1 lines, where the ith line (counting from 0) in the upper half (including the middle) is formed as follows:

$$\text{line}_i = \text{spaces}(n-i-1) + "*" + \begin{cases} \text{spaces}(2i-1) + "*" & \text{if } i > 0 \\\ \text{(nothing)} & \text{if } i = 0 \end{cases}$$

The lower half is the mirror image of the upper half (excluding the middle line). Moreover, you will be provided with multiple diamond sizes. Your task is to output all the diamonds, and separate consecutive diamonds by an empty line.

Note: All formulas are represented in LaTeX format.

inputFormat

The input is read from stdin and consists of multiple lines. The first line contains an integer d, representing the number of diamond patterns. Each of the following d lines contains an integer n (with n ≥ 1), representing the size of a diamond.

For example:

2
3
4

outputFormat

The output is written to stdout and consists of the diamond patterns corresponding to each given size. Each diamond is printed as 2n-1 lines. Separate consecutive diamonds by exactly one blank line (i.e. an empty line).

For example, for an input of size 3, the output should be:

  *
 * *
*   *
 * *
  *
## sample
1
1
*