回答編集履歴
1
修正
test
CHANGED
@@ -18,15 +18,11 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
-
// row行 col列 の神経衰弱
|
22
|
-
|
23
21
|
int row = 6;
|
24
22
|
|
25
23
|
int col = 8;
|
26
24
|
|
27
25
|
assert( row*col % 2 == 0 );
|
28
|
-
|
29
|
-
|
30
26
|
|
31
27
|
int num = row * col / 2;
|
32
28
|
|
@@ -46,23 +42,13 @@
|
|
46
42
|
|
47
43
|
// row行col列の行列を用意して、ナカミをdataで埋める
|
48
44
|
|
49
|
-
int i = 0;
|
50
|
-
|
51
45
|
int** matrix = new int* [row];
|
52
46
|
|
53
47
|
for ( int r = 0; r < row; ++r ) {
|
54
48
|
|
55
|
-
matrix[r] =
|
49
|
+
matrix[r] = data + r*col;
|
56
|
-
|
57
|
-
for ( int c = 0; c < col; ++c ) {
|
58
|
-
|
59
|
-
matrix[r][c] = data[i++];
|
60
|
-
|
61
|
-
}
|
62
50
|
|
63
51
|
}
|
64
|
-
|
65
|
-
delete[] data; // dataは用済み
|
66
52
|
|
67
53
|
|
68
54
|
|
@@ -84,13 +70,9 @@
|
|
84
70
|
|
85
71
|
// あとしまつ
|
86
72
|
|
87
|
-
|
73
|
+
delete[] matrix;
|
88
74
|
|
89
|
-
delete[] matrix[r];
|
90
|
-
|
91
|
-
}
|
92
|
-
|
93
|
-
delete[]
|
75
|
+
delete[] data;
|
94
76
|
|
95
77
|
}
|
96
78
|
|