Runtime Error (NZEC) in simple code

前端 未结 6 1135
没有蜡笔的小新
没有蜡笔的小新 2020-12-11 05:41

I\'m getting runtime error (NZEC) when running the following code over at SPOJ. I\'d be very thankful if any of you would kindly point out what\'s going on.

         


        
6条回答
  •  臣服心动
    2020-12-11 06:20

    For Java, NZEC is returned when the code throws an exception. For problems on Spoj, etc often the last line in the input causes this exception if the test cases are not terminated by an identifier string.

    For such cases, a useful hack is to wrap your code in a try - catch and simply return if there's an exception. The caught exception signals that you've reached the end of input.

    public static void main(String[] args) {
        temp program = new temp();
        try{
        program.begin();
        } catch(Exception e){
            return;
        }
    }
    

提交回复
热议问题