I am using codechef for the first time. I am trying to run this simple code in Java but it
is giving an NZEC error everytime and I can’t figure out why :
public class Main{
public static void main(String[] args) throws java.io.IOException {
java.io.BufferedReader f = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
int i = 0;
i = Integer.parseInt(f.readLine().trim());
while(i!=42)
{
System.out.println(i);
i = Integer.parseInt(f.readLine().trim());
}
f.close();
}
}
This the problem - http://www.codechef.com/problems/TEST
The problem just asks to read one or two digit integers and print them back until 42 is encountered. The code is running fine on my personal computer. Please help me out.
I tried it and there is problem with f.close(). In fact I have no idea why this is a problem, but when I tried to comment this statement it’s ok (it gets AC).
public class Main {
private static int position=0;
private static ArrayList ints=new ArrayList();
public static void main(String args[]) throws Exception
{