zoukankan      html  css  js  c++  java
  • POJ 3085:Quick Change

    Quick Change
    Time Limit: 1000MS   Memory Limit: 65536K
    Total Submissions: 6111   Accepted: 4358

    Description

    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 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)

    Source

    你  离  开  了  ,  我  的  世  界  里  只  剩  下  雨  。  。  。

    #include <stdio.h>
    int main()
    {
        int n,c,q,d,x;
        int i;
        scanf("%d", &n);
        for (i = 1; i <= n; i++)
        {
            q = 0, d = 0, x = 0;
            scanf("%d", &c);
            q = c / 25;
            c = c % 25;
            d = c / 10;
            c = c % 10;
            x = c / 5;
            c = c % 5;
            printf("%d %d QUARTER(S), %d DIME(S), %d NICKEL(S), %d PENNY(S)
    ", i, q, d, x, c);
        }
        return 0;
    }
    

  • 相关阅读:
    非嵌入式数据库 软件很难普及 玩大
    FireMonkey下的异形窗体拖动(需要使用FmxHandleToHwnd函数转化一下句柄)
    公司开到高新技术区可以只收11的企业所得税,拿到软件企业认证后可享受所得税两免三减半(从盈利年度算起)
    猜测:信号槽的本质是使用Windows的自定义消息来实现的
    服务运行、停止流程浅析
    在线压缩JS的工具
    通用流程设计
    并行Linq(一)
    SQL基础知识总结(一)
    Easyui布局
  • 原文地址:https://www.cnblogs.com/im0qianqian/p/5989583.html
Copyright © 2011-2022 走看看