Search

이차배열3_개념03_길이다른이차원

대분류
STEP08 이차배열
문제 난이도
필수
소분류
이차배열3_개념

영상

개념

<script> /* [개념] 길이가 다른 이차원 배열 이차원 배열은 길이를 다르게 구성할 수도 있다. */ let a = [ [1, 2, 3, 4], [1, 2], [1, 2, 3, 4, 5] ]; for(let i=0; i<a.length; i++) { document.write(a[i] + "<br>"); } document.write("---------<br>"); let b = []; let c = [1, 2, 3]; let d = [1, 2]; let e = [1, 2, 3, 4, 5]; b.push(c); b.push(d); b.push(e); for(let i=0; i<b.length; i++) { document.write(b[i] + "<br>"); } document.write("---------<br>"); let f = []; for(let i=0; i<3; i++) { let r = Math.floor(Math.random() * 9) + 1; let temp = []; for(let j=0; j<r; j++) { temp.push(j); } f.push(temp); } for(let i=0; i<f.length; i++) { document.write(f[i] + "<br>"); } </script>
Java
복사