1

I am trying to answer the following question. Tested on my IDE and it is compiling fine but on the site, it throws following error:

runtime error (NZEC) edit    ideone it

Please advice what am doing wrong.

Link to SPOJ Site

Question rewrite small numbers from input to output. Stop processing input after reading in the number 42. All numbers at input are integers of one or two digits.

Answer

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        int i = 0;

        while (i != 42){

            Scanner s = new Scanner(System.in);
            i = s.nextInt();
            System.out.println(i);
        }
    }
}
kang
  • 707
  • 4
  • 17
  • Not certain of what you're describing, but try move ` Scanner s = new Scanner(System.in);` to before the loop. – Evan Knowles Jan 20 '17 at 11:37
  • 1
    Those kind of site usally doesn't support the Scanner but provide a method to get the input. Search on the forum about that – AxelH Jan 20 '17 at 11:43
  • Personal note : this question seems a bite old, the forum about this question is flood with non-english language, so you might not found any help. Here, this seems a bite random (some good answer aren't validated) – AxelH Jan 20 '17 at 11:46
  • Try other question, more recent maybe. And see if there is some documentation about how to use there compiler. PS : Evan comment point out something that you should do – AxelH Jan 20 '17 at 11:50
  • At least an explanation for `NZEC` can be found on the [SPOJ tutorial](http://www.spoj.com/tutorials/USERS/). – SubOptimal Jan 20 '17 at 12:29

0 Answers0