import java.util.Scanner;
public class Main
{
public static void main(String[]args){
Scanner kb=new Scanner(System.in);
int n=0;
while(n!=42)
{System.out.print("");
int a=kb.nextInt();
n=a;
if(n!=42)
{System.out.println(n);}}
System.exit(1);}}
when I submit it I get a NZEC runtime error
please help!
Don’t Use Public class
and try now ??
The public class is obviously necessary.
Some guidelines given here: http://www.codechef.com/wiki/sample-solutions#Java
. I was having the same problem. I tried using the InputStreamReader instead of the Scanner and it worked for me. InputStreamReader is also much faster than Scanner for large inputs, however less convenient.
Don’t really know if and why Scanner is a problem, let me know if you find out.
Try using return instead of System.exit(). My guess is that exit value 1 indicates some kind of error is Codechef’s environment.
yup, return fixed it .thanks for the help everyone.