打印三角形

package test;

public class 打印三角形 {
public static void main(String[] args) {
for (int i = 1;i<=5;i++){//先赋值一个变量,确定其行数
for (int f = 5;f>i;f--){//在每行中确定空白数
System.out.print(" ");
}
for (int f = 0;f<i;f++){//在每行中确定字符数
System.out.print("*");
}
for (int f = 0;f+1<i;f++){//打印另一半
System.out.print("*");
}
System.out.println();
}
}
}
posted @ 2021-12-25 20:27  ∷牧野苍枚∷  阅读(28)  评论(0)    收藏  举报