import java.util.Scanner;
class baoshi{
public static void main(String[] args) {
int x,y,z;
int a,b,c;
int m,n;
System.out.println("请输入菱形的高:");
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
m = n/2;
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||x==y*2-1){
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==m+1||a==b||b-1==0||a==b*2-1){
System.out.print("* ");
}
else
System.out.print(" ");
}
System.out.println();
}
}
}
}
java宝石
猜你喜欢
转载自blog.csdn.net/weixin_42939672/article/details/83215901
今日推荐
周排行