encrypt 문제 런타임오류가 뜹니당 한번만 봐주세요

  • mozell
    mozell
    import java.util.Scanner;
    
    public class Main{      
        static public void main(String args[]){
    
            String[] temp=null; // 스트링 입력 배열
            String[] result; // 결과 배열
            int testcase=0;      // 테스트 케이스 
    
            Scanner value1 = new Scanner(System.in);
            //System.out.print("input TestCase number(1~10) : ");
            testcase = value1.nextInt();
            temp = new String[testcase];
            result = new String[testcase];
            for(int i=0;i<testcase;i++){
                result[i]="";
                temp[i]="";
            } // 초기화
    
            try{
                if(testcase < 1 || testcase>10) throw new Exception("Wrong number ! : "+testcase); 
            }
            catch(Exception e){
                e.printStackTrace();
                e.getMessage();
            } // 테스트 케이스 입력
    
            for(int i=0; i<testcase ; i++){
                Scanner value2 = new Scanner(System.in);
                //System.out.print("input String for encrypt : ");
                temp[i] = value2.nextLine();
                try{
                    if (temp[i].length()>100) throw new Exception("Wrong size ! : "+temp[i].length());
                }
                catch(Exception e){
                    e.getMessage();
                }
            } // 문자열 입력
    
            for(int i=0; i<testcase; i++){
                temp[i]+="";
                for(int j=0;j<temp[i].length();j++){
                    if(j%2==0)
                        result[i]+=temp[i].charAt(j);
                }
                for(int j=0;j<temp[i].length();j++){
                    if(j%2==1)
                        result[i]+=temp[i].charAt(j);
                }
            } // encrypt 시키기
    
            for(int i=0;i<testcase;i++){
                System.out.println(result[i]);
            } // 출력
    
        }
    }
    

    ENCRYPT 풀고있는데요 이문제 계속 런타임 오류떠서 뭐가 문제인지 봐주실수 있나요 RTE (nonzero return code)가 뜹니다.


    7년 전
1개의 댓글이 있습니다.
  • hyunhwan
    hyunhwan

    new Scanner(System.in)를 여러차례 하셔서 문제가 발생한 것 같습니다. value2를 사용한 부분을 value1으로 바꿔보세요.


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