for循环打印三角形
for循环打印三角形
基本思想 :先打印几个空格,在打印几个 *
package com.zhou.struct;
//打印5行的三角形
public class TestDemo01 {
public static void main(String[] args) {
for(int i=1;i<=5;i++){
for(int j=5;j>=i;j--){
System.out.print(" ");
}
for (int j=1;j<=i;j++){
System.out.print("*");
}
for(int j=1;j<i;j++){
System.out.print("*");
}
System.out.println();
}
}
}
浙公网安备 33010602011771号