- 289 名前:デフォルトの名無しさん mailto:sage [2009/10/03(土) 00:40:13 ]
- >>287
import java.io.*; class k3_1 { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new FileReader("test2.txt")); double[] test = new double[5]; for (int i = 0; i < test.length; i++) { String str = br.readLine(); test[i] = Double.parseDouble(str); } double max = test[0], min = test[0], s1 = 0, s2 = 0; for (int i = 0; i < test.length; i++) { if (max < test[i]) max = test[i]; if (min > test[i]) min = test[i]; s1 += test[i] / test.length; s2 += test[i] * test[i] / test.length; System.out.println(test[i]); } System.out.println("最高点は" + max + "です"); System.out.println("最低点は" + min + "です"); System.out.printf("標準偏差は%7.5fです%n", Math.sqrt(s2 - s1 * s1)); br.close(); } catch (IOException e) { System.out.println("入出力エラーです"); } } }
|

|