简单贪心算法问题--找零钱
来源:互联网 发布:高中教学视频 淘宝网 编辑:程序博客网 时间:2024/06/05 02:49
问题:
很简单,先找面值大的。
#include<iostream>using namespace std;void find_change(int total_change){ int Q, D, N, P; Q = D = N = P = 0; if ((total_change / 25 > 0) && (total_change > 10)) { Q = total_change / 25; } int total_change_D = total_change % 25; if ((total_change_D / 10 > 0) && (total_change > 5)) { D = total_change_D / 10; } int total_change_N = total_change_D % 10; if ((total_change_N / 5 > 0) && (total_change_D > 1)) { N = total_change_N / 5; } P = total_change_N % 5; cout << "quarters Q = " << Q << endl; cout << "dimes D = " << D << endl; cout << "nickles N = " << N << endl; cout << "pennies P = " << P << endl;}int main(){ int amount = 0; cout << "Please input the changes you need: " << endl; cin >> amount; find_change(amount); return 0;}
0 0
- 简单贪心算法问题--找零钱
- 贪心算法解决找零钱问题
- 贪心算法——找零钱问题
- 贪心算法解决找零钱问题
- 贪心算法找零钱
- 找零钱(贪心算法)
- 找零钱的贪心算法
- 贪心算法之找零钱
- 找零钱问题—贪心
- 找零钱问题的贪心算法(java描述)
- C++实现贪心算法-找零钱
- 贪心算法——找零钱
- XYNUOJ 1259 找零钱—贪心算法
- 数据结构--贪心算法解决找零钱问题 这里用的是人民币()
- 找零钱问题(C语言实现)——贪心算法应用(1)
- 找零钱问题(C语言实现)——贪心算法应用(1)
- 贪心算法实例:找零钱(Java实现)
- 贪心算法(找零钱、活动安排)java实现
- ccf Z字形扫描 30行版
- linux下Ping工具的C语言实现
- Android-从音频文件中获取专辑图片
- Web URL中对特殊字符的处理
- 获取网络视频缩略图
- 简单贪心算法问题--找零钱
- tjut 4643
- redis:info详解
- Git git pull error
- C 内存管理详解
- 用file类进行单文件上传
- iOS开发:捕获程序崩溃
- OpenCV3.0.0下的视频稳像代码,效果不错哦!
- SQL Server中用While循环替代游标(Cursor)的解决方案