东华大学 2022 oj c++ 无超纲写法 发工资咯

AC代码:

#include<iostream>
#include<iomanip>
#include<math.h>
#include<cstring>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<bits/stdc++.h>
int count(int money)//对每一位员工计数 人民币一共有100元、50元、20元、10元、5元、2元和1元七种
{
	int cnt = 0;
	if (money >= 100)
	{
		cnt = cnt + money / 100;
		money %= 100;
	}
	if (money >= 50)
	{
		cnt = cnt + money / 50;
		money %= 50;
	}
	if (money >= 20)
	{
		cnt = cnt + money / 20;
		money %= 20;
	}
	if (money >= 10)
	{
		cnt = cnt + money / 10;
		money %= 10;
	}
	if (money >= 5)
	{
		cnt = cnt + money / 5;
		money %= 5;
	}
	if (money >= 2)
	{
		cnt = cnt + money / 2;
		money %= 2;
	}
	if (money >= 1)
	{
		cnt = cnt + money / 1;
		money %= 1;
	}
	return(cnt);
};
using namespace std;
int main()
{
	//测试函数是否正确:cout << count(197);
	int t=0;
	cin >> t;
	int n = 0;
	while (cin >> n, t--)
	{
		int ans = 0;
		int a[110];
		for (int i = 1; i <= n; i++)
		{
			cin >> a[i];
			ans += count(a[i]);
		}
		cout << ans << endl;
	}
	//system("pause");
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值