标题:c++ 如何解决:将一笔零钱.,换成5分、2分和1分的硬币--的问题
只看楼主
哈哈哈1234
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2009-11-2
结帖率:0
 问题点数:0 回复次数:0 
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);
    }
}
搜索更多相关主题的帖子: 硬币 
2009-11-02 22:15



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-290819-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.094685 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved