Loading...
Loading...
Loading...
Print an n × n square of stars where only the border is drawn. The inside is filled with spaces.
* on the border, a space inside.Example
Input
4
Output
**** * * * * ****
The first and last rows are full; the middle rows have a star at each end.
Try the problem first. Open one hint at a time.
Go over every cell with two loops: row i and column j, both from 1 to n.
A cell is on the border when it is in the first or last row, or in the first or last column.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor