Java(Array)_Exam_05

2024. 10. 24. 17:35·Java/기초 내용 정리

2024-10-24

 

 1	 6	11	16	21	
 2	 7	12	17	22	
 3	 8	13	18	23	
 4	 9	14	19	24	
 5	10	15	20	25

 

package exam;

public class Exam_05 {

	public static void main(String[] args) {
		
		//  1. 다차원 배열 선언 및 배열 메모리 할당.
		int[][] score = new int[5][5];
		
		int count = 1;
		
		//  2. 5행5열 다차원 배열에 데이터를 저장해 보자
		for(int i=0; i<score.length; i++) {		  //  고정 - 열
			
			for(int j=0; j<score[i].length; j++) {	  //  값 변동 - 행		
				
				score[j][i] = count++;
				
				//count++;
			}
		}
		
		//  3. 저장된 다차원 배열을 화면에 출력해 보자
		for(int i=0; i<score.length; i++) {
			
			for(int j=0; j<score[i].length; j++) {
				
				System.out.printf("%2d\t", score[i][j]);
			}
			System.out.println();
		}
	}

}

'Java > 기초 내용 정리' 카테고리의 다른 글

Java(Class&Method)_Method_01  (0) 2024.10.24
Java(Array)_Exam_06  (0) 2024.10.24
Java(Array)_Exam_04  (0) 2024.10.24
Java(Array)_Exam_03  (0) 2024.10.24
Java(Array)_Exam_02  (0) 2024.10.24
'Java/기초 내용 정리' 카테고리의 다른 글
  • Java(Class&Method)_Method_01
  • Java(Array)_Exam_06
  • Java(Array)_Exam_04
  • Java(Array)_Exam_03
mw41817
mw41817
일생의 개발 기록 저장소
  • mw41817
    IT 개발 일지
    mw41817
    • Index (487)
      • HTML (36)
        • 기초 내용 정리 (36)
      • CSS (29)
        • 기초 내용 정리 (29)
      • JavaScript (60)
        • 기초 내용 정리 (60)
      • JQuery (38)
        • 기초 내용 정리 (38)
      • Java (232)
        • 기초 내용 정리 (232)
      • JSP (46)
        • 기초 내용 정리 (46)
      • Spring, Boot (31)
        • 기초 내용 정리 (31)
      • DB (5)
        • Oracle SQL (5)
      • Code WorkBook (6)
        • programmers (6)
        • Baekjoon (0)
      • 기타 (1)
        • 유용한 사이트 (3)
  • 전체
    오늘
    어제
  • 글쓰기 관리
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
    • 카테고리
    • 주인장 GitHub
  • 공지사항

  • 인기 글

  • 태그

    html #코딩 #프로그래밍 #기초
  • 최근 댓글

  • hELLO· Designed By정상우.v4.10.0
mw41817
Java(Array)_Exam_05
상단으로

티스토리툴바