How do I align an empty triangle?

  • 0
    Hi, the challenge is to draw an empty triangle.
    Here's 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();
            }
        }
    }

    It turned out to be a bit crooked:


    Should be like this:


    But the triangle turns out to be some kind of curve, something is confused. Where is the actual error in the code?
    Java Anonymous, Aug 8, 2019

  • 1 Answers
  • 0
    It's only stretched because you have a stretched font in your console.

    You have one problem - one asterisk is missing in the lower right corner (you need to ask k & lt; = count).
    Caleb Flynn

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!