Answer the question
In order to leave comments, you need to log in
How to align an empty triangle?
Hello, the task is to draw an empty triangle.
Here is what he wrote
public class Test {
public static void main(String[] args) {
int count = 12;
for (int i = 5; i < count; i++) {
for (int k = 0; k < count; k++) {
if (i == count - 1 || k == count - 1 - i || k == i + 1) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}
Answer the question
In order to leave comments, you need to log in
It's only stretched because you have a stretched font in the console.
You have one problem - there is not enough asterisk one in the lower right corner (you need to fix k <= count).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question