public class Main { public static void main(String[] args) { //空心三角形 int n=3; for (int i = 1; i <=n; i++) { for (int j = 1; j <=n-i; j++) { System.out.print(" "); } for (int j = 1; j <=i*2-1; j++) { if(i==1||i==n) System.out.print("*"); else if(j==1||j==i*2-1) System.out.print("*"); else System.out.print(" "); } System.out.println(); } } }
0.0分
0 人评分