+ 1
Please explain how this code works
1 Odpowiedź
+ 1
It's supposed to create a n by n box. The box is represented by a matrix.
"i" is the row number. "j" the column number.
First row is line (all stars). Thus the "i == 1" condition. No matter which column, there will be a star.
The same goes for the last row which is the "i == n" condition.
For any other row, only the beginning and end have stars. Expressed by conditions "j == 1" and "j == n".
The if statement will print star if any of the conditions are true. Expressed by the logical or statements "||".