第23691题 单选题
下列实现金额最少币种兑换的C++代码采用的算法是?
#include <iostream>
using namespace std;

#define N_COINS 7
int coins[N_COINS] = {100, 50, 20, 10, 5, 2, 1}; //货币面值,单位相同
int coins_used[N_COINS];

void find_coins(int money) {
    for (int i = 0; i < N_COINS; i++) {
        coins_used[i] = money / coins[i];
        money = money % coins[i];
    }
    return;
}
int main() {
    int money;
    cin >> money;    //输入要换算的金额
    find_coins(money);
    for (int i = 0; i < N_COINS; i++)
        cout << coins_used[i] << endl;
    return 0;
}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析