1.題目說明:
請將檔案另存成JPA05.java,並編譯為JPA05.class
2.設計說明:
(1)設陣列A的維度為4*2*3,試在程式碼裡宣告此一陣列,並在宣告同時設定初值,然後計算陣列A內的所有元素總和(SUM)。
(2)int A[][][]={{{1,2,3},{4,5,6}},
{{7,8,9},{10,11,12}},
{{13,14,15},{16,17,18}},
{{19,20,21},{22,23,24}}};
- public class JPD05 {
- public static void main(String[] argv) {
- int sum =0;
- int A[][][] = {{{1,2,3},{4,5,6}},
- {{7,8,9},{10,11,12}},
- {{13,14,15},{16,17,18}},
- {{19,20,21},{22,23,24}}};
-
-
-
- System.out.printf("sum = %d\n", sum);
- }
- }
複製代碼 |