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

Input not closing
Posted by Kevin 25 Aug 2016 19:29
I've perused over some of the other solutions here, tried to come up with something original, but I'm having a difficult time understanding why it won't stop letting me input in Eclipse, and how to deal with that...Here's my code:

import java.util.*;

public class ReverseRoot
{//start class
    public static void main(String[] args)
    {//start main
        Scanner in = new Scanner(System.in);
        ArrayList<Long> array = new ArrayList<Long>();
        array.add(in.nextLong());

        while(in.hasNextLong())
        {
            array.add(in.nextLong());
        }
        in.close();

        for (int i = array.size(); i > 0; i--)
            System.out.printf("%.4f%n", Math.sqrt((double)array.get(i)));
    }//end main
}//end class
Re: Input not closing
Posted by pasharik 30 Oct 2016 22:25
Try to run program from command line:
java Solution < 1.txt
And 1.txt contains list of numbers, like below:
1
2
3

Edited by author 30.10.2016 22:25