This commit is contained in:
krahets
2023-10-18 02:16:55 +08:00
parent 64c5d13051
commit d2ba55fcd6
22 changed files with 374 additions and 436 deletions

View File

@ -428,12 +428,10 @@ comments: true
```c title="fractional_knapsack.c"
/* 物品 */
struct Item {
typedef struct {
int w; // 物品重量
int v; // 物品价值
};
typedef struct Item Item;
} Item;
/* 分数背包:贪心 */
float fractionalKnapsack(int wgt[], int val[], int itemCount, int cap) {

View File

@ -264,7 +264,7 @@ comments: true
```c title="coin_change_greedy.c"
/* 零钱兑换:贪心 */
int coinChangeGreedy(int* coins, int size, int amt) {
int coinChangeGreedy(int *coins, int size, int amt) {
// 假设 coins 列表有序
int i = size - 1;
int count = 0;