k****e 发帖数: 297 | 1 来个通俗版本
默认硬币从大到小排列:
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 *... 阅读全帖 |
|