File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
src/main/java/practiceJAVA Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ package practiceJAVA ;
2+
3+ public class MultidimensionalArray {
4+ public static void main (String [] args ) {
5+ // ๋ฐฐ์ด ์์ฑ
6+ int [][] scores = {
7+ {90 ,90 ,96 },
8+ {80 ,81 }
9+ };
10+
11+ // ๋ฐฐ์ด์ ๊ธธ์ด
12+ System .out .printf ("1์ฐจ์ ๋ฐฐ์ด์ ๊ธธ์ด๋ %d์
๋๋ค.\n " , scores .length ); // 2
13+ System .out .printf ("2์ฐจ์ ๋ฐฐ์ด์ ์ฒซ๋ฒ์งธ ๊ธธ์ด๋ %d์
๋๋ค.\n " , scores [0 ].length ); // 3
14+
15+ // ํน์ ์์ ์ถ๋ ฅ
16+ System .out .printf ("์ฒซ๋ฒ์งธ ๋ฐ์ ๋๋ฒ์งธ ํ์์ ์ ์๋: %d์
๋๋ค. \n " , scores [0 ][1 ]);
17+
18+ // ํ์ฉ1. ํ๊ท ๊ตฌํ๊ธฐ
19+ int averageScore = 0 ;
20+ int sum = 0 ;
21+ int count = 0 ;
22+ for (int i =0 ; i <scores .length ; i ++) {
23+ for (int j =0 ; j < scores [i ].length ; j ++) {
24+ sum += scores [i ][j ];
25+ count += 1 ;
26+ }
27+ }
28+ System .out .printf ("์ด ํ๊ท ์ %f์ ์
๋๋ค.\n " , sum /(double )count );
29+
30+ }
31+
32+ }
You canโt perform that action at this time.
0 commit comments