public static void main(String[] args) { //两种声明写法 // int a[][][] = {{{1, 2}, {3, 4, 5}}, {{6, 7}, {8, 9, 10, 11}}}; int[][][] a = {{{1, 2}, {3, 4, 5}}, {{6, 7}, {8, 9, 10, 11}}}; // 输出各个元素,求各元素之和 int sum = 0; for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[i].length; j++) { for (int k = 0; k < a[i][j].length; k++) { System.out.println(a[i][j][k]); sum +=a[i][j][k]; } } } System.out.println(\"和为\"+sum); }
来源:https://www.cnblogs.com/c2g5201314/p/15962845.html
本站部分图文来源于网络,如有侵权请联系删除。