题目:打印出如下图案(菱形) * *** ****** ******** ****** *** *
时间: 2023-12-07 18:02:12 浏览: 71
以下是Java语言实现打印菱形的代码:
```java
public class Main {
public static void main(String[] args) {
print();
}
public static void print() {
for (int i = 0; i < 4; i++) {
for (int j = 3 - i; j > 0; j--) {
System.out.print(" ");
}
for (int k = 0; k <= 2 * i; k++) {
System.out.print("*");
}
System.out.println();
}
for (int x = 3; x > 0; x--) {
for (int y = 3 - x + 1; y > 0; y--) {
System.out.print(" ");
}
for (int z = 0; z <= 2 * x - 2; z++) {
System.out.print("*");
}
System.out.println();
}
}
}
```
阅读全文