[Solved] How Can I Make Perfect Acute Triangle with for loop?


Just Change Inner for loop : here for k=i-1 as you are checking for i>9 and i<9 so 11 will be excluded. I guess you are trying to manage space between two digit and one digit number. But you can just use single for i<=10 and double space for i>10

       for (int k = 20; k > i - 1; k--) {
            if (i <= 10) {
                System.out.print(" "+(20 - i));//Single Space
            } else if (i > 10) {
                System.out.print("  "+(20 - i));//Double Space
            }
        }

NOTE:This triangle may look weird little bit

1

solved How Can I Make Perfect Acute Triangle with for loop?