一共848种方案
C++源码如下:
int total = 150;
int coin5 = 5;
int coin2 = 2;
int coin1 = 1;
int combinations = 0;
int count5 = (total/coin5);
for(; count5 >= 0; count5--)
{
int count2 = ((total - count5 * coin5)/coin2);
for(;count2 >= 0;count2--)
{
int count1 = (total - count5 * coin5 - count2 * coin2);
if((count1 + count2 + count5)<= 100)
{
combinations ++;
printf("第%d种方法是:%d,%d,%d\t",combinations,count5,count2,count1);
}
}
}
温馨提示:答案为网友推荐,仅供参考