mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 16:54:50 +08:00
Update 0518.零钱兑换II.md
0518.零钱兑换II新增C语言实现
This commit is contained in:
@ -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#
|
### C#
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
public class Solution
|
public class Solution
|
||||||
{
|
{
|
||||||
@ -378,3 +399,4 @@ public class Solution
|
|||||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||||
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
|
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user