sum of periphery
Submit solution
Points:
10 (partial)
Time limit:
1.0s
Memory limit:
256M
Authors:
Problem type
Allowed languages
Java 19, Java 8
題目說明
程式輸入二維陣列,將陣列最外圍的元素加總然後輸出一個總和數字。
輸入
陣列的橫列數量、陣列的直行數量、恰好可以填滿陣列的所有元素
輸入值範圍
橫列數量>=1,直行數量>=1,除此之外,所有數字都是大於等於0且小於等於1000的整數。
輸出
陣列外圍的數字總和
sample input1
3 3 1 2 3 4 5 6 7 8 9
sample output1
40
說明
1 2 3
4 5 6
7 8 9
因為以上陣列最外圍的數字加總是 1 + 2 + 3 + 4 + 6 + 7 + 8 + 9
sample input2
3 3 1 0 1 0 1 0 1 0 1
sample output2
4
說明
1 0 1
0 1 0
1 0 1
因為以上陣列最外圍的數字加總是 1 + 1 + 1 + 1
Comments