Java 为什么我的代码给出NZEC(运行时错误)

Java 为什么我的代码给出NZEC(运行时错误),java,runtime-error,Java,Runtime Error,我的代码在我的系统上运行良好,但在在线系统上提供NZEC static String fun (String str,int n) throws Exception { String concat=""; if(n==0) return str; else { concat=str+rev(str); return fun(concat,(n-1)); } } 功能-2 static String re

我的代码在我的系统上运行良好,但在在线系统上提供NZEC

static String fun (String str,int n) throws Exception
{
    String concat="";

    if(n==0)
        return str;
    else
    {
        concat=str+rev(str);
        return fun(concat,(n-1));
    }

}
功能-2

static String rev(String str) throws Exception
{   
    StringBuffer br=new StringBuffer(str);
    br.reverse();
    String revstr=br.toString();
    return revstr;

}
主要功能

public static void main(String[] args) throws IOException {
    try
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int test=Integer.parseInt(br.readLine());

        for(int p=0;p<test;p++)
        {
            String sub="";
            int count=0;
            String[] line=br.readLine().split(" ");
            String finalstr=fun(line[0],Integer.parseInt(line[1]));
            int length=finalstr.length();

            for( int c = 0 ; c < length ; c++ )
            {
                for( int i = 1 ; i <= length - c ; i++ )
                {
                    sub = finalstr.substring(c, c+i);
                    int subcheck=Integer.parseInt(sub)%1000000007;

                    if(subcheck%3==0)
                    {
                        count++;

                    }
                }
            }
            System.out.println(count);

        }
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }

}
publicstaticvoidmain(字符串[]args)引发IOException{
尝试
{
BufferedReader br=新的BufferedReader(新的InputStreamReader(System.in));
int test=Integer.parseInt(br.readLine());

对于(int p=0;p我在Hackerearth上尝试了您的代码:请参阅:

它起作用了

我不知道您的输入……但我认为您在将此行中的非常大的数字解析为整数时会遇到问题:

            int subcheck=Integer.parseInt(sub)%1000000007;

我添加了catch NumberFormatException以查看更多详细信息。

只需谷歌搜索您试图解决的Java挑战和“NZEC”,然后阅读众多发现中的一个。什么意思:“在线系统上的NZEC”??@elefasGR这是一个挑战性的问题……我在线提交代码,但它给了我NZEC,我只想知道背后的主要原因。@Tom我做了……但没有令人满意的结果。Tok发现,“NZEC”表示“非零退出代码”,以帮助其他人理解它的含义