输出显示如下图案(菱形):+*++*+*+*++*+*+*+*++*+*+*+*+*++*+*+*+*++*+*+*++*+...
时间: 2023-12-14 20:33:08 浏览: 113
以下是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();
}
}
}
```
输出结果为:
```
*
***
*****
*******
*****
***
*
```
阅读全文