for循环06(打印正三角形)

package com.lyc.struct;

public class TestDemo01 {
public static void main(String[] args) {
//打印5行三角形

for (int i = 1; i <= 5; i++) {
for (int j = 5; j >= i; j--){
System.out.print(" ");
}
for (int k = 1; k <= i; k++) {
System.out.print("*");
}
for (int t = 1; t < i; t++){
System.out.print("*");
}
System.out.println();
}

}
}
/*
运行结果:

    *
   ***
  *****
 *******
*********

*/
原文地址:https://www.cnblogs.com/liuyunche/p/14247354.html