public class Test {
public static void main(String[] args) {
makeShape(28); // 指定菱形的,,, 叫宽高什么的 菱形 有宽高吗 数学都忘了~
}
public static void makeShape(int needLength) {
if (needLength > 30) {
System.out.println("不要太过分!日");
return;
}
for (int i = 0; i < needLength; i++) {
for (int j = i; j < needLength-1; j++) {
System.out.print(" ");
}
for (int j = 0; i >= j; j++) {
System.out.print("* ");
}
System.out.println();
}
for (int i = 0; i < needLength; i++) {
for (int j = 0; i >= j; j++) {
System.out.print(" ");
}
for (int j = i; j < needLength-1; j++) {
System.out.print("* ");
}
System.out.println();
}
}
} |