Java经典练习题19

/*
题目:打印出如下图案(菱形)         
*       ***     *****    *******     *****       ***        *   
*/
public class Class19 {

public static void main(String[] args) {
int Height = 7;
int Weight = 7;
for(int i = 0; i < (Height + 1) / 2; i++){
for(int j = 0; j < Weight/2 - i; j++){
System.out.print(" ");
}
for(int k = 1; k < (i + 1)*2; k++){
System.out.print("*");
}
System.out.println();
}
for(int i = 0; i < Height / 2; i++){
for(int j = 0; j <= i; j++){
System.out.print(" ");
}
for(int k = 0; k < Weight - 2*(i+1); k++){
System.out.print("*");
}
System.out.println();
}

/*
if(i < 3){
int star = 1;
int black = 3;
for(int j = 0; j < black; j++){
System.out.print(" ");
}
for(int t = 0; t < star; t++){
System.out.print("*");
}
star += 2;
black -= 1;
System.out.println();
}else if(i == 3){
int star = 7;
int black = 0;
for(int j = 0; j < black; j++){
System.out.print(" ");
}
for(int t = 0; t < star; t++){
System.out.print("*");
}
System.out.println();
}else{
int star = 5;
int black = 1;
for(int j = 0; j < black; j++){
System.out.print(" ");
}
for(int t = 0; t < star; t++){
System.out.print("*");
}
star -= 2;
black += 1;
System.out.println();
}
}
*/
}
}

原文地址:https://www.cnblogs.com/zhuozige/p/12358619.html