java 数字菱形简单代码

 1 public class number {
 2 
 3 public static void main(String[] args) {
 4 
 5 int i=1,j=1;
 6 for (i=-8;i<=8;i++)
 7 {
 8 for(j=1;j<=8+9-Math.abs(i);j++) {
 9 if(9-Math.abs(i)+j<=9)
10 System.out.print(" ");
11 else
12 System.out.print(1+Math.abs(9-j));
13 
14 }
15 System.out.println();
16 }
17 }
18 
19 }

 

 

 

posted @ 2021-12-07 20:45  芸小宇  阅读(414)  评论(0)    收藏  举报