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 1001. Reverse Root

Where is my fault ?
Posted by Nikolai 9 Oct 2017 00:46
import java.util.Scanner;

public class main {
    public static void main(String[] args) throws Exception {

        Scanner scan = new Scanner(System.in);

        String a = scan.nextLine();
        double b = Double.parseDouble(a);
        double c;
        double d = b;

        double mass[] = new double[(int)b];

        while (b != 0) {
            c = Math.sqrt(scan.nextDouble());
            mass[(int)(b - 1)] = c;
            b--;
        }
        for (double i = 0; i < d; i++) {
            System.out.printf("%.4f\n", mass[(int)i]);
        }
    }
}

Outputs "Runtime error"

Edited by author 09.10.2017 00:50
Re: Where is my fault ?
Posted by ToadMonster 9 Oct 2017 12:32
Please look at example, try to find count of inputs you are reading into b.