ECNU1042. 付款问题

返回目录

题目链接
在这里插入图片描述

#include <bits/stdc++.h>
using namespace std;

int main() {
    
    
    int n;
    long long money;
    cin>>n;
    int mach[7]={
    
    100,50,20,10,5,2,1};
    while(n--){
    
    
        scanf("%lld",&money);
        int out[7]={
    
    0};
        int pos=0;
        while(money!=0){
    
    
            int t=money/mach[pos];
            if(t!=0){
    
    
                out[pos]=t;
                money-=(t*mach[pos]);
            }
            pos++;
        }
        for(int i=0;i<7;i++){
    
    
            printf("%d",out[i]);
            if(i!=6) printf(" ");
            else printf("\n");
        }
    }
}

猜你喜欢

转载自blog.csdn.net/a1920993165/article/details/129381475