【发布时间】:2016-03-16 21:24:09
【问题描述】:
我尝试了 codechef 的一个问题,并在 java 上编写了我的代码,该代码在我的笔记本电脑上的 eclipse 上完美运行。但每次我尝试提交代码时,它都会给我这个 NZEC 错误。 谁能告诉我为什么在执行此代码时出现非零退出代码错误(NZEC)。 这段代码的问题:https://www.codechef.com/problems/STRPALIN
import java.util.*;
import java.io.*;
public class Palindrome {
public boolean check() throws IOException{
String A;
String B;
BufferedReader inp = new BufferedReader (new InputStreamReader(System.in));
A=inp.readLine();
B=inp.readLine();
for(int i=0;i<A.length();i++)
{
for(int j=0;j<B.length();j++)
{
if(A.charAt(i)==B.charAt(j))
return true;
}
}
return false;
}
public static void main(String[] args)throws NumberFormatException, IOException {
Palindrome M = new Palindrome();
boolean[] array = new boolean[10];
BufferedReader in = new BufferedReader (new InputStreamReader(System.in));
int T = Integer.parseInt(in.readLine());
for(int i=0;i<T;i++)
{
array[i]=M.check();
}
for(int j=0;j<T;j++){
if(array[j])
System.out.println("Yes");
else
System.out.println("No");
}
}
}
【问题讨论】:
-
如果你使用
System.exit(0)作为你执行的最后一行会发生什么? -
总是把你的代码放在
trycatchblock中。
标签: java runtime-error