teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

コードの修正

2019/07/05 21:08

投稿

kazuma-s
kazuma-s

スコア8222

answer CHANGED
@@ -13,9 +13,9 @@
13
13
  ```C
14
14
  #include <stdio.h>
15
15
 
16
- typedef struct { int w_i, v_i; } Good;
16
+ typedef struct { int w_i, v_i; } Goods;
17
17
 
18
- Good *g;
18
+ Goods *g;
19
19
  int n, W, w, v, max_v;
20
20
 
21
21
  void knapsack(int i)
@@ -32,13 +32,13 @@
32
32
 
33
33
  int main(void)
34
34
  {
35
- Good good1[4] = { {2, 3}, {1, 2}, {3, 4}, {2, 2} };
35
+ Goods g1[4] = { {2, 3}, {1, 2}, {3, 4}, {2, 2} };
36
- g = good1, n = 4, W = 5, max_v = 0;
36
+ g = g1, n = 4, W = 5, max_v = 0;
37
37
  knapsack(0);
38
38
  printf("%d\n", max_v);
39
39
 
40
- Good good2[3] = { {2, 2}, {2, 1}, {1, 1} };
40
+ Goods g2[3] = { {2, 2}, {2, 1}, {1, 1} };
41
- g = good2, n = 3, W = 5, max_v = 0;;
41
+ g = g2, n = 3, W = 5, max_v = 0;;
42
42
  knapsack(0);
43
43
  printf("%d\n", max_v);
44
44
  }