diff --git a/problems/0518.零钱兑换II.md b/problems/0518.零钱兑换II.md index da1c4755..59fdf6cd 100644 --- a/problems/0518.零钱兑换II.md +++ b/problems/0518.零钱兑换II.md @@ -353,7 +353,28 @@ object Solution { } } ``` +## C + +```c +int change(int amount, int* coins, int coinsSize) { + int dp[amount + 1]; + memset(dp, 0, sizeof (dp)); + dp[0] = 1; + // 遍历物品 + for(int i = 0; i < coinsSize; i++){ + // 遍历背包 + for(int j = coins[i]; j <= amount; j++){ + dp[j] += dp[j - coins[i]]; + } + } + return dp[amount]; +} +``` + + + ### C# + ```csharp public class Solution { @@ -378,3 +399,4 @@ public class Solution +