由买买提看人间百态

topics

全部话题 - 话题: ancoin
(共0页)
k****e
发帖数: 297
1
来自主题: JobHunting版 - 求教硬币组合问题
来个通俗版本
默认硬币从大到小排列:
void GetCombinationSet(const int *anCoin, int *anCount, int x, int i)
{
if(x>anCoin[i])
{
if (i {
int *anCountNew = new int[g_nCoinType];
CopyArray(anCount, anCountNew);
GetCombinationSet(anCoin, anCountNew, x, i+1);
}
anCount[i]++;
GetCombinationSet(anCoin, anCount, x-anCoin[i], i);
}
else if (x == anCoin[i])
{
if (i {
int *... 阅读全帖
(共0页)