hdu ——Quick Change

本文介绍了一个简单的找零程序设计任务,旨在帮助用户快速准确地计算出顾客应找回的零钱中各种硬币的数量,包括25美分的硬币(quarters)、10美分的硬币(dimes)、5美分的硬币(nickels)和1美分的硬币(pennies)。程序通过输入待找零的金额,并采用最小数量硬币的原则进行计算。

J.P. Flathead’s Grocery Store hires cheap labor to man the checkout stations. The people he hires (usually high school kids) often make mistakes making change for the customers. Flathead, who’s a bit of a tightwad, figures he loses more money from these mistakes than he makes; that is, the employees tend to give more change to the customers than they should get.

Flathead wants you to write a program that calculates the number of quarters ($0.25), dimes ($0.10), nickels ($0.05) and pennies ($0.01) that the customer should get back. Flathead always wants to give the customer’s change in coins if the amount due back is $5.00 or under. He also wants to give the customers back the smallest total number of coins. For example, if the change due back is $1.24, the customer should receive 4 quarters, 2 dimes, 0 nickels, and 4 pennies.

 

Input

The first line of input contains an integer N which is the number of datasets that follow. Each dataset consists of a single line containing a single integer which is the change due in cents, C, (1 ≤ C ≤ 500).

 

Output

For each dataset, print out the dataset number, a space, and the string:

Q QUARTER(S), D DIME(S), n NICKEL(S), P PENNY(S)

Where Q is he number of quarters, D is the number of dimes, n is the number of nickels and P is the number of pennies.

 

Sample Input
3 124 25 194
 

Sample Output
1 4 QUARTER(S), 2 DIME(S), 0 NICKEL(S), 4 PENNY(S) 2 1 QUARTER(S), 0 DIME(S), 0 NICKEL(S), 0 PENNY(S) 3 7 QUARTER(S), 1 DIME(S), 1 NICKEL(S), 4 PENNY(S)
 
#include <iostream>
using namespace std;

int main()
{
    int q, d, n, p;
    int m;
    cin >> m;
    int i = 0;
    while (cin >> m)
    {
        q = m/25;
        m %= 25;

        d = m/10;
        m %= 10;

        n = m/5;
        m %= 5;

        p = m;

        i++;

        cout << i << " " << q << " QUARTER(S), " << d << " DIME(S), " << n << " NICKEL(S), " << p << " PENNY(S)" << endl;
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值