개발자 톡
연습문제 톡
진정한 효도
TC 4,8,10
- 등록일
- 2024-02-23 00:42:33
- 조회수
- 309
- 작성자
- sbp0604
Scanner sc = new Scanner(System.in); int[][] data = new int[3][3]; for (int i=0; i<3; i++) { data[i][0] = sc.nextInt(); data[i][1] = sc.nextInt(); data[i][2] = sc.nextInt(); }; int minN = 2; for(int i=0; i<3; i++) { if(data[i][0] == data[i][1] && data[i][1]== data[i][2] ) { minN = 0; break; } else { int abs1 = Math.abs(data[i][0] - data[i][1]); int abs2 = Math.abs(data[i][0] - data[i][2]); int abs3 = Math.abs(data[i][1] - data[i][2]); if( abs1 == 2 || abs2 == 2 || abs3 == 2) { minN = 2; } else { minN = 1; } } }; if(minN != 0) { for(int i=0; i<3; i++) { if(data[0][i] == data[1][i] && data[1][i]== data[2][i] ) { minN = 0; break; } else { int abs1 = Math.abs(data[0][i] - data[1][i]); int abs2 = Math.abs(data[0][i]- data[2][i]); int abs3 = Math.abs(data[1][i] - data[2][i]); if(abs1 == 2 || abs2 == 2 || abs3 == 2) { minN = 2; } else { minN = 1; } } }; } System.out.println(minN);
4, 8, 10번이 틀렸는데 뭐가 문제일까요 ㅠ
#진정한_효도