#t96. 小杨的 N 字矩阵

小杨的 N 字矩阵

Xiaoyang's N-Shaped Matrix

Problem Description

Xiaoyang wants to construct an m×mm \times m N-shaped matrix (where mm is odd). In this matrix, the diagonal from the top-left to the bottom-right, the 1st column, and the mm-th column are all made of the half-width plus sign +, while all other positions are the half-width minus sign -. For example, a 5×55 \times 5 N-shaped matrix looks like:

+---+
++--+
+-+-+
+--++
+---+

Please help Xiaoyang print the corresponding N-shaped matrix for a given mm.

Input Format

One line containing a single positive integer mm.

Output Format

Output the corresponding N-shaped matrix.

Sample Input

5

Sample Output

+---+
++--+
+-+-+
+--++
+---+

Sample Explanation

When m=5m = 5, we need a 5×55 \times 5 matrix. Following the rules:

  • The 1st column (the 1st character of each row) and the last column (the 5th column) are both +.
  • On the diagonal from top-left to bottom-right, the positions where the row index equals the column index are also +: the 1st row 1st column, 2nd row 2nd column, ..., 5th row 5th column.
  • All other positions are -.

Constructing row by row gives the matrix shown in the sample output.

Constraints

Guaranteed 3≤m≤493 \le m \le 49 and mm is odd.