개발자 톡

연습문제 톡 진정한 효도

어떤게 틀린걸까요...ㅠㅠㅠㅠㅠ

등록일
2024-03-26 21:28:03
조회수
184
작성자
tjdrbs7844

import java.io.*;

import java.util.*;


public class Main {


  public static void main(String[] args) throws Exception{

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

     

    int[][] Array = new int[3][3];


    for (int i=0; i<3; i++){

      StringTokenizer st = new StringTokenizer(in.readLine());

      for(int j=0; j<3; j++){

        Array[i][j] = Integer.parseInt(st.nextToken());

      }

    }

    int count = 0;

    int[] Arr = new int[3];

    int[] Arr2 = new int[3];


    for(int j=0; j<3; j++){

      for (int i=1; i<2; i++){

        if(Array[j][i-1] + Array[j][i] + Array[j][i+1] == 3){

          count = 0;

        }else{

          count = Array[j][i-1] + Array[j][i] + Array[j][i+1] -3;

        }

      }

      Arr[j] = Integer.parseInt(String.valueOf(count));

    }

     

    for(int j=0; j<3; j++){

      for (int i=1; i<2; i++){

        if(Array[i-1][j] + Array[i][j] + Array[i+1][j] == 3){

          count = 0;

        }else{

          count = Array[i-1][j] + Array[i][j] + Array[i+1][j] -3;

        }

      }

      Arr2[j] = Integer.parseInt(String.valueOf(count));

       

    }

     

    int[] arr3 = new int[Arr.length + Arr2.length];

    System.arraycopy(Arr, 0, arr3, 0, Arr.length);

    System.arraycopy(Arr2, 0, arr3, Arr.length, Arr2.length);


    Arrays.sort(arr3);

     

    System.out.println(arr3[0]);

  }

}


제가 이해한 문제는 이렇게 하면 맞는데 틀린 경우의 수를 잘 모르겠습니다...

선생님들 한번만 봐주세요 부탁드립니다...


#진정한_효도

이 카테고리의 톡 더보기