Plus Star Pattern
Given a positive odd integer n, return an n by n plus sign made from stars. A cell contains a star when its row is the center row or its column is the center…
Given a positive odd integer n, return an n by n plus sign made from stars. A cell contains a star when its row is the center row or its column is the center column; every other cell is a space. Preserve leading spaces, remove trailing spaces from each row, join adjacent rows with one newline character, and do not add a trailing newline.
- 1 ≤ n ≤ 9 - n is always odd. - The output contains exactly n rows.
Example 1: input n = 5; output * * ***** * *. Index 2 is the center. The center row is full, and every other row marks only column 2.
Example 2: input n = 1; output *. The only cell is both the center row and center column.
Category: Pattern Programs. Topic: pattern-programs. Difficulty: Easy. Patterns: math.