QUADTREE nonzero return code) 가 계속 나옵니다.

  • dreamplayer
    dreamplayer

    nonzero return code) 가 계속 나옵니다.
    어떤부분이 문제인지 알수 있나요?
    QUADTREE 문제입니다..

    package quardtree;
    
    import java.util.Scanner;
    
    
    public class Main {
        static int current=0;
        static int depth = 0;
        static String[] input = new String[50];
        static String[] output = new String[50];
    
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int caseNum = sc.nextInt();
    
            for(current=0; current<caseNum; current++){
                Scanner sc2 = new Scanner(System.in);
                input[current] =sc2.nextLine();
                if(input[current].charAt(0)=='x')
                    output[current] = changeDraw(0);
                else
                    output[current] = input[current];
                depth = 0;
            }
    
            for(int i=0; i<caseNum; i++)
                System.out.println(output[i]);
            return;
        }
    
        public static String changeDraw(int index){
            String temp ="";
            String result="x";
            int mid=0;          //중간
            int len=0;
            index++;            //끝 +1
            int count=0;    //4번씩 카운트
            String temp2="";
            while(count<4){
                if(input[current].charAt(index)== 'x'){
                    temp2 = changeDraw(index);
                    len+= temp2.length();
                    index+= temp2.length();
                    temp +=temp2;
                }
                else{
                    temp += input[current].charAt(index);
                    len += 1;
                    index +=1;
                }
                count++;
                if(count==2)
                    mid=len;
            }
            result +=temp.substring(mid, len);
            result +=temp.substring(0, mid);
            return result;
        }
    }
    

    10년 전
3개의 댓글이 있습니다.
  • hydrogen
    hydrogen

    main 함수에 return 0; 대신 다른 값을 리턴하신게 아닐까요?


    10년 전 link
  • dreamplayer
    dreamplayer

    튜트리얼 보면 void Main()해도 문제 없는거 같은데...
    그래서 int로 고쳐봤는데도 역시나 nonzero return code..뭐가 문제일까요..


    10년 전 link
  • Being
    Being

    예제 입출력에 대한 동작을 확인해 보신 코드인가요? java.util.Scanner 인스턴스를 여러 개 생성하는 것이 문제가 되어 입력을 정상적으로 받지 못하고 있습니다. (이와 별개로 mainvoid로 두셔도 괜찮습니다)


    10년 전 link
  • 정회원 권한이 있어야 커멘트를 다실 수 있습니다. 정회원이 되시려면 온라인 저지에서 5문제 이상을 푸시고, 가입 후 7일 이상이 지나셔야 합니다. 현재 문제를 푸셨습니다.