ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1000. A+B Problem

I don't know, why it crashes
Posted by mari 2 Feb 2011 16:51
Here is my solution. It works fine in eclipse, but it crashes in here.
Could you tell me what is wrong?

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Sum {

    public static void main(String[] args) {

    int x,y;
    long z;

    try {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        x = Integer.parseInt(bf.readLine());
        y = Integer.parseInt(bf.readLine());
        bf.close();
        z = x+y;
        System.out.println(z);
    } catch (IOException e) {
        System.out.println(e);
    }

    }
}
Re: I don't know, why it crashes
Posted by Alexey Dergunov [Samara SAU] 2 Feb 2011 23:47
Test: 1 2 (in one line)
Verdict: Crash

Besides BufferedReader use java.util.StringTokenizer (better) or java.io.StreamTokenizer.