c++ 如何解决:将一笔零钱.,换成5分、2分和1分的硬币--的问题
输出使用语句:printf("fen5:%d,fen2:%d,fen1:%d,total:%d\n",fen5, fen2, fen1, fen5+fen2+fen1);输入输出示例:括号内为说明
输入:
2 (repeat=2)
10 (money=10分)
13 (money=13分)
输出:
fen5:1,fen2:2,fen1:1,total:4
fen5:1,fen2:1,fen1:3,total:5
count = 2 (10分有2种换法)
fen5:2,fen2:1,fen1:1,total:4
fen5:1,fen2:3,fen1:2,total:6
fen5:1,fen2:2,fen1:4,total:7
fen5:1,fen2:1,fen1:6,total:8
count = 4 (13分有4种换法)
#include "stdio.h"
int main(void)
{
int count, fen1, fen2, fen5, money;
int repeat, ri;
scanf("%d", &repeat);
for(ri = 1; ri <= repeat; ri++){
scanf("%d", &money);
/*---------*/
printf("count = %d\n", count);
}
}