for(int num = 0 ;num < dp.length+dp[0].length-1;num++) {
for(int i = 0;i < dp.length ;i++) {
int j = num - i;
if((j >= 0) && (j < dp[0].length)) {
System.out.print(dp[i][j]);
}
}
System.out.println();
}
原二维数组:
000010000
000000000
000010000
000000000
000000000
000000000
000000000
010000000斜向遍历结果:
0
00
000
0000
10000
000000
0010000
00000000
00000001
0000000
000000
00000
0000
000
00
0