#include <cstdio>
using namespace std;
int main(){
double N;
int zh;
int c[6]={100,50,20,10,5,2};
int b[6] = {100, 50, 25, 10, 5, 1};
scanf("%lf",&N);
int amount = (int)(N * 100 + 0.5);
printf("NOTAS:\n");
for(int i=0;i<6;i++){
zh = amount/(c[i]*100);
printf("%d nota(s) de R$ %d.00\n",zh,c[i]);
amount %= (c[i] * 100);
}
printf("MOEDAS:\n");
for(int i=0;i<6;i++){
zh = amount/b[i];
printf("%d moeda(s) de R$ %.2f\n",zh,b[i]/100.00);
amount %= b[i];
}
return 0;
}
关键在于避免double精度丢失问题,于是全部转化为“分”的级别进行处理。