poj3085

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,count=0;
    scanf("%d",&n);
    while(n--)
    {
        int tmp;
        scanf("%d",&tmp);
        printf("%d ",++count);
        printf("%d QUARTER(S), ",tmp/25);
        tmp%=25;
        printf("%d DIME(S), ",tmp/10);
        tmp%=10;
        printf("%d NICKEL(S), ",tmp/5);
        tmp%=5;
        printf("%d PENNY(S)
",tmp/1);
    }
    return 0;
}
View Code

大概思路就是贪心,从大的开始到小的

技巧:小于一个数去除这个数,得0,求余又是他本身,遍历一遍就行

原文地址:https://www.cnblogs.com/gabygoole/p/4590335.html