题目描述:
假设1元,5元,10元,50元,100元的人民币若干,实现一个能找到最少张数累计达到一个指定金额方法。如:67元,可分为67个1元钱。也可分为6个10元7个1元,其中最少人民币分法为一张50元,一张10元,一张5元,两张1元,五张不同金额的拆分方法为最最少张数拆分法。

要求实现函数:
void CalLeastChange(long lInputValue, int *iOutputRlt)
【输入】 lInputValue: 输入整数金额
【输出】 lOutputRlt: 输出计算结果
【注意】仅考虑整数金额拆分方法
示例
输入:“67”
输出:“5”

#include<iostream>
using namespace std; void CalLeastChange(long lInputValue, int *iOutputRlt)
{
int highNum=lInputValue/(*);
int lowerNum=lInputValue-(lInputValue/)*;
int curNum=(lInputValue/)%; int count=highNum;
if(curNum>=)
{
count++;
curNum-=;
}
count=count+curNum; if(lowerNum>=)
{
count++;
lowerNum-=;
}
count=count+lowerNum; *iOutputRlt=count; cout<<*iOutputRlt<<endl; } int main()
{
int lInputValue=;
int lInputValue1=;
int iOutputRlt[]={};
CalLeastChange(lInputValue,iOutputRlt);
CalLeastChange(lInputValue1,iOutputRlt);
return ;
}

最新文章

  1. 当前不会命中断点。源代码与原始版本不同 (VS2012)
  2. 我的mysql测试环境
  3. tpch-kudu
  4. 运行时报错 ADB server didn’t ACK
  5. asp.net &lt;% %&gt;,&lt;%# %&gt;,&lt;%= %&gt;,&lt;%$ %&gt;区别大集合
  6. linux下安装
  7. Unity3D 之UGUI 图片
  8. [topcoder]BestRoads
  9. 《python基础教程》笔记之 列表
  10. Python 3从入门到精通01-环境搭建
  11. pat 1022 digital library
  12. &quot;Uncaught object angular.js:36&quot;诡异错误
  13. Redis in .NET Core 入门:(4) LIST和SET
  14. 键值对的算子讲解 PairRDDFunctions
  15. mysql5.5被django抛弃,安装mysql5.7记录
  16. 【Python026--字典内键方法】
  17. ssm项目中 数据库和资源的备份
  18. 在centos6中编译安装httpd-2.4/搭建LAMP
  19. Elasticsearch搜索异常-------org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper: parse_exception
  20. Linux下Shell元字符的释义

热门文章

  1. Linux强行踢用户
  2. 4 Python+Selenium的元素定位方法(link/partial link)
  3. 我的C++笔记(类与对象)
  4. SpringMVC(三)@PathVariable
  5. 【Vue+Node】解决axois请求数据跨域问题
  6. Python中生成器,迭代器,以及一些常用的内置函数.
  7. Kattis - iBoard
  8. JS 马托货物
  9. echart全局属性,自用,搜索比较快
  10. 运用cat EOF添加文件