回答編集履歴
1
コードの修正
test
CHANGED
@@ -28,11 +28,11 @@
|
|
28
28
|
|
29
29
|
|
30
30
|
|
31
|
-
typedef struct { int w_i, v_i; } Good;
|
31
|
+
typedef struct { int w_i, v_i; } Goods;
|
32
32
|
|
33
33
|
|
34
34
|
|
35
|
-
Good *g;
|
35
|
+
Goods *g;
|
36
36
|
|
37
37
|
int n, W, w, v, max_v;
|
38
38
|
|
@@ -66,9 +66,9 @@
|
|
66
66
|
|
67
67
|
{
|
68
68
|
|
69
|
-
Good g
|
69
|
+
Goods g1[4] = { {2, 3}, {1, 2}, {3, 4}, {2, 2} };
|
70
70
|
|
71
|
-
g = g
|
71
|
+
g = g1, n = 4, W = 5, max_v = 0;
|
72
72
|
|
73
73
|
knapsack(0);
|
74
74
|
|
@@ -76,9 +76,9 @@
|
|
76
76
|
|
77
77
|
|
78
78
|
|
79
|
-
Good g
|
79
|
+
Goods g2[3] = { {2, 2}, {2, 1}, {1, 1} };
|
80
80
|
|
81
|
-
g = g
|
81
|
+
g = g2, n = 3, W = 5, max_v = 0;;
|
82
82
|
|
83
83
|
knapsack(0);
|
84
84
|
|