#t96. 小杨的 N 字矩阵
小杨的 N 字矩阵
Xiaoyang's N-Shaped Matrix
Problem Description
Xiaoyang wants to construct an N-shaped matrix (where is odd). In this matrix, the diagonal from the top-left to the bottom-right, the 1st column, and the -th column are all made of the half-width plus sign +, while all other positions are the half-width minus sign -. For example, a N-shaped matrix looks like:
+---+
++--+
+-+-+
+--++
+---+
Please help Xiaoyang print the corresponding N-shaped matrix for a given .
Input Format
One line containing a single positive integer .
Output Format
Output the corresponding N-shaped matrix.
Sample Input
5
Sample Output
+---+
++--+
+-+-+
+--++
+---+
Sample Explanation
When , we need a 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 and is odd.