package superlily.control;
public class PrintTriangle {
public static void main(String[] args) {
for (int i = 1; i <=5; i++) { //Tips: input "5.for" in IntelliJ IDEA, it will generate this line automatically
for (int j = 5; j >= i; j--) { //j>=i 保证每一行比上一行少1, 并注意最后是j-- 不是++哦
System.out.print(" "); //打印左边空格的部分
}
for (int j = 1; j < 2*i; j++) { //j<2*i保证打出来的*是奇数 1、3、5、7、9
System.out.print("*");
}
System.out.println();
}
}
}
*
***
*****
*******
*********
Process finished with exit code 0