编程题#4:人民币支付
描述
从键盘输入一指定金额(以元为单位,如345),然后输出支付该金额的各种面额的人民币数量,显示100元,50元,20元,10元,5元,1元各多少张,要求尽量使用大面额的钞票。
输入
一个小于1000的正整数。
输出
输出分行,每行显示一个整数,从上到下分别表示100元,50元,20元,10元,5元,1元人民币的张数
#include <iostream> using namespace std; int main() { int n, a, b, c, d, e, f; cin >> n; a = n / 100; b = n % 100 / 50; c = n % 50 / 20; d = n % 50 % 20 / 10; e = n % 50 % 10 / 5; f = n % 5; cout << a << endl << b << endl << c << endl << d << endl << e << endl << f << endl; return 0; }
人一我百,人十我万!自己选择的路,跪着也要走完。
浙公网安备 33010602011771号