parent
0a30cd7a26
commit
4e7637556b
|
|
@ -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>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue