|
|
back to boardWhy crash ? Help please import java.util.Scanner; import java.text.*; public class Main { public static void main (String [] args) { Scanner kb = new Scanner (System.in); DecimalFormat df = new DecimalFormat("#.0000"); int dem = 0; String inra; double [] data = new double [50000]; while (kb.hasNextDouble()) { data[dem] = kb.nextDouble (); dem++; } for (int i = dem-1; i >= 0; i--) { inra = df.format (Math.sqrt(data[i])); if (inra.charAt (0) == '.') inra = "0" + inra; System.out.println (inra); }
} } Re: Why crash ? Help please I used List<Double> = new ArrayList<Double>(); and it worked without crash. ---- public class Main { public static void main (String [] args) { ... String inra; List<Double> coll = new ArrayList<Double>(); while (kb.hasNextDouble()) { coll.add(kb.nextDouble()); } for(int j = coll.size() - 1; j >= 0; j--) { inra = df.format (Math.sqrt(coll.get(j))); if (inra.charAt (0) == '.') inra = "0" + inra; System.out.println (inra); } } } ---- or following will work double [] data = new double [140000]; Edited by author 25.01.2013 22:05 Edited by author 25.01.2013 22:05 Edited by author 25.01.2013 22:41 Re: Why crash ? Help please Posted by Your_Y 2 Feb 2013 14:57 FUCK?????? |
|
|