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宝石
最新推荐文章于 2021-03-15 10:28:36 发布