2 / 2
Mar 2018

Receive this “runtime error (NZEC)” when send code to check. When compiling this code on my computer it works. Please, help.

import java.util.Scanner;

class sample2 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int k=sc.nextInt();
		for(int j=0;j<k;j++){
			int a=sc.nextInt()+1;
			int sum=0;
			for(int i=a;i>0;i++){
				int t=a;
				while(a>0){
					sum=(sum*10)+a%10;
					a=a/10;
				}
				if(sum==t){
					System.out.println(sum);
					break;

				}
				else{
					sum=0;
					a=i+1;
				}
			}
		}
	}
}
  • created

    Mar '18
  • last reply

    Mar '18
  • 1

    reply

  • 926

    views

  • 2

    users

Ask yourself these questions:

  1. What is the biggest number an int can hold?
  2. What does the problem statement say about how big K can be?

See the problem?