题目描述 第一次写题解233
算法$O(n)$
遍历2个半次=遍历1次
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
double M;
int a[12]={10000, 5000, 2000, 1000, 500, 200, 100, 50, 25, 10, 5, 1};
scanf("%lf", &M);
int BigM = M*100;
puts("NOTAS:");
for (int i = 0; i < 6; i++){
printf("%d nota(s) de R$ %d.00\n", BigM / a[i], a[i] / 100);
BigM %= a[i];
}
puts("MOEDAS:");
double b[6] = {1, 0.50, 0.25, 0.10, 0.05, 0.01}; //float可能快一丢丢
for (int i = 6; i<12; i++){
printf("%d moeda(s) de R$ %.2f\n", BigM / a[i], b[i-6]);
BigM %= a[i];
}
return 0;
}