1216:找零钱
来源:互联网 发布:晒书房软件 编辑:程序博客网 时间:2024/05/16 05:06
1216:找零钱
Description
在售货员向顾客找零钱时,一般都是尽可能找最少数量的钱币给顾客。下面将给出一定数额的人民币,请将其分解为数量最少的货币。货币单位仅有100 50 20 10 5 2 1几个币种。
Input
一个整数,即人民币总额(单位元)。
Output
分解后的人民币序列,用回车分割。
Sample Input
19
Sample Output
10
5
2
2
#include<iostream>using namespace std;int main(){ int x1,x2,x3,x4,x5,x6,x7; int n,i; cin>>n; x1=n/100; n=n%100; x2=n/50; n=n%50; x3=n/20; n=n%20; x4=n/10; n=n%10; x5=n/5; n=n%5; x6=n/2; n=n%2; x7=n; for (int i = 0; i < x1; i++) cout<<"100"<<endl; for (int i = 0; i < x2; i++) cout<<"50"<<endl; for (int i = 0; i < x3; i++) cout<<"20"<<endl; for (int i = 0; i < x4; i++) cout<<"10"<<endl; for (int i = 0; i < x5; i++) cout<<"5"<<endl; for (int i = 0; i < x6; i++) cout<<"2"<<endl; for (int i = 0; i < x7; i++) cout<<"1"<<endl; return 0; }
阅读全文
0 0
- 1216: 找零钱
- 1216:找零钱
- 找零钱
- 找零钱
- 找零钱
- 找零钱
- 找零钱
- 找零钱!
- 找零钱
- 找零钱
- 找零钱
- 找零钱
- 找零钱
- 找零钱
- 找零钱
- 找零钱
- 找零钱
- 找零钱
- Java对XML文档进行解析(JAXP-DOM解析)
- CodeForces
- C++ boost
- PCL 中 pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr 出现incomplete type is not allowed 的解决方法
- Java环境变量以及eclipse的配置
- 1216:找零钱
- Activity 启动模式
- 仿今日头条
- jsp页面根据json数据动态生成table
- [初学笔记] matlab中怎么把数据循环写入txt文件
- Verilog学习基本语法篇
- java中关于transient关键字小结
- 安装包安全测试
- HDU