import java.util.Scanner;
public class klingxing{
public static void main(String[] args){
int x,y,z;
int a,b,c;
int m;
System.out.println("请输入三角形的高:");
Scanner sc = new Scanner(System.in);
m = sc.nextInt();
for(x=1;x<=m;x++){
for(z=m+1;z>x;z--){
System.out.print(" ");
}
for(y=1;y<=x;y++){
if(x==y||y-1==0){
System.out.print("* ");
}
else
System.out.print(" ");
}
System.out.println();
}
for(a=m+1;a>0;a--){
for(c=m+1;c>a;c--){
System.out.print(" ");
}
for(b=1;b<=a;b++){
if(a==b||b-1==0){
System.out.print("* ");
}
else
System.out.print(" ");
}
System.out.println();
}
}
}
java空心菱形for循环
猜你喜欢
转载自blog.csdn.net/weixin_42939672/article/details/82858372
今日推荐
周排行