代码如下
void main() {
int a, b, c,d=0;
for (a = 0; a <= 4; a++) {
for (b = 0; b <= 10; b++) {
for (c = 0; c <= 20; c++)
if (5 * a + 2 * b + c==20) {
printf("有%d个1元+%d个2元+%d个5元\n", c, b, a);
d++;
}
}
}
printf("共%d种方案", d);
}
void main()
{
int t,a1,a2,a5;
for(a1=0;a1<20;a1++)
{
for(a2=0;a2<20;a2++)
{
for(a5=0;a5<20;a5++)
{
if(a1+a2*2+a5*5==20)printf("1$*%02d,2$*%02d,5$*%02d\r\n",a1,a2,a5);
}
}
}
}