質問編集履歴
2
修正しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,22 +2,84 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
|
5
|
+
import java.io.BufferedReader;
|
6
6
|
|
7
|
-
|
7
|
+
import java.io.File;
|
8
8
|
|
9
|
-
|
9
|
+
import java.io.FileReader;
|
10
10
|
|
11
|
-
for(int j=0;j<3;j++) {
|
12
11
|
|
13
|
-
data1[i][j]=Double.parseDouble(data[i][j]);
|
14
12
|
|
15
|
-
|
13
|
+
public class Aip4 {
|
16
14
|
|
15
|
+
public static void main(String args[]) {
|
16
|
+
|
17
|
+
BufferedReader br = null;
|
18
|
+
|
19
|
+
String fn = "data.csv"; // 入力ファイル
|
20
|
+
|
21
|
+
// データの最大個数
|
22
|
+
|
23
|
+
final int mn = 10;
|
24
|
+
|
25
|
+
// データを格納する2次元配列
|
26
|
+
|
27
|
+
String data[][] = new String[mn][];
|
28
|
+
|
29
|
+
double data1[][] =new double[mn][];
|
30
|
+
|
31
|
+
double b[][] =new double[3][3];//クラスタの中心座標
|
32
|
+
|
33
|
+
int c=3;
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
try {
|
38
|
+
|
39
|
+
File file = new File(fn);
|
40
|
+
|
41
|
+
br = new BufferedReader(new FileReader(file));
|
42
|
+
|
43
|
+
// readLineで一行ずつ読み込む
|
44
|
+
|
45
|
+
int index = 0;
|
46
|
+
|
47
|
+
String line;
|
48
|
+
|
49
|
+
while ((line = br.readLine()) != null) {
|
50
|
+
|
51
|
+
// lineをカンマで分割し、配列dataに保持
|
52
|
+
|
53
|
+
data[index] = line.split(",");
|
54
|
+
|
55
|
+
index++;
|
56
|
+
|
17
|
-
|
57
|
+
}
|
58
|
+
|
59
|
+
//string[][]dataをdouble[][]に型変換
|
60
|
+
|
61
|
+
for(int i=0;i<10;i++) {
|
62
|
+
|
63
|
+
for(int j=0;j<3;j++) {
|
64
|
+
|
65
|
+
data1[i][j]=Double.parseDouble(data[i][j]);
|
66
|
+
|
67
|
+
System.out.println(data1[i][j]);
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
System.out.println();
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
}catch (Exception e) {
|
78
|
+
|
79
|
+
System.out.println(e.getMessage());
|
80
|
+
|
81
|
+
}
|
18
82
|
|
19
83
|
}
|
20
84
|
|
21
|
-
|
22
|
-
|
23
|
-
|
85
|
+
}
|
1
修正しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
String
|
5
|
+
String data[][]=new String[10][3];
|
6
6
|
|
7
|
-
double d[][]=new double[10][3];
|
7
|
+
double data1[][]=new double[10][3];
|
8
8
|
|
9
9
|
for(int i=0;i<10;i++) {
|
10
10
|
|