|
|
вернуться в форумInput not closing Послано Kevin 25 авг 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 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 |
|
|