Skip to content

Commit

Permalink
5.9. Крест в псевдографике;
Browse files Browse the repository at this point in the history
  • Loading branch information
Temzor committed Sep 25, 2023
1 parent 820a360 commit 04f7922
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/ru/j4j/loop/Slash.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ public class Slash {
public static void draw(int size) {
for (int row = 0; row < size; row++) {
for (int cell = 0; cell < size; cell++) {
boolean left = (row + cell) % 2 == 0;
boolean left = row == cell; /* добавить условие для левой диагонали - с левого верхнего угла в правый нижний*/
boolean right = size - row - 1 == cell; /* добавить условие для правой диагонали - из левого нижнего в правый верхний*/
if (left) {
System.out.print("0");
} else if (right) {
System.out.print("0");
} else {
System.out.print("X");
System.out.print(" ");
}
}
System.out.println();
Expand Down

0 comments on commit 04f7922

Please sign in to comment.