Java 面試題:印出三角形

public void printTriangle(int height) {
    int space = height - 1;
    int star = 1;
    
    for (int i = 0; i < height; i++) {
        
        for (int j = 0; j < space; j++) {
        	System.out.print(" ");
        }
        for (int j = 0; j < star; j++) {
        	System.out.print("*");
        }
        
        space--;
        star += 2;
        System.out.println();
    }
}

結果
printTriangle(5);