forked from mouredev/retos-programacion-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasjordi.java
22 lines (20 loc) · 823 Bytes
/
asjordi.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public class Triforce {
public static void main(String[] args) {
print(3);
}
public static void print(int rows){
for (int row = 0; row < rows * 2; row++) {
if (row < rows) {
String startSpace = " ".repeat(((2 * rows) - 1) - row);
String printRow = "*".repeat((2 * (row + 1)) - 1);
System.out.println(startSpace + printRow);
} else {
int currentRow = row - rows;
String startSpace = " ".repeat((rows - currentRow) - 1);
String middleSpace = " ".repeat((2 * (rows - currentRow)) - 1);
String printRow = "*".repeat((2 * (currentRow + 1)) - 1);
System.out.println(startSpace + printRow + middleSpace + printRow);
}
}
}
}