## 数组实现矩阵逐层向内层加1 顶原

q
quyunde

package java1701;

public class javaMain {

public static void main(String[] args) {
// 逐层加
// 1 1 1 1 1  1   1 1 1 1 1   1 1 1 1   1 1 1
// 1 2 2 2 2  1   1 2 2 2 1   1 2 2 1   1 2 1
// 1 2 3 3 2  1   1 2 3 2 1   1 2 2 1   1 1 1
// 1 2 3 3 2  1   1 2 2 2 1   1 1 1 1
// 1 2 2 2 2  1   1 1 1 1 1
// 1 1 1 1 1 1
show();
}

public static void show() {
int w = 11;//图形宽度
int[][] arr = new int[w][w];

for (int ceng = 1; ceng <= (w + 1) / 2; ceng++) {
doWork(ceng, w ,arr);//i是数字层数及数字
}
//打印数组
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
System.out.print(arr[i][j]+" ");
}
System.out.println();
}
}

public static void doWork(int ceng, int width,int[][] arr) {
for (int i = ceng-1; i < width-ceng+1; i++) {
for (int j = ceng-1; j < width-ceng+1; j++) {
arr[i][j]=ceng;
}
}
}

}

q

### quyunde

package java1701; public class javaMain { public static void main(String[] args) { // 逐层加 // 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 // 1 2 2 2 2 1 1 2 2 2 1 1 2 2 1 1 2 1 // 1 2......

quyunde
2017/02/23
0
0

AI研习社
2017/09/27
0
0
Keras 文档阅读笔记（不定期更新）

xuruilong100
06/05
0
0

2018/07/19
0
0

2018/05/30
0
0

28分钟前
4
0

30分钟前
4
0

Tronlong创龙
43分钟前
4
0

aiChuang
43分钟前
4
0
McDonald’s is using Alexa and Google to accepting job applications

McDonald’s today announced a new initiative the fast food chain is calling the “Apply Thru,” in which owners of Amazon Alexa or Google Assistant devices can begin job applic......

wowloop
47分钟前
5
0