AcWing 656. 钞票和硬币
原题链接
中等
作者:
Value
,
2020-09-09 09:04:03
,
所有人可见
,
阅读 604
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
double m; cin >> m;
int a = int(m);
int b = int(m * 100 - a * 100);
cout << "NOTAS:" << endl;
double notes[6] = {100, 50, 20, 10, 5, 2};
for(int i = 0; i < 6; i ++ ){
printf("%d nota(s) de R$ %.2lf\n", a / int(notes[i]), notes[i]);
a %= int(notes[i]);
}
b += a * 100;
cout << "MOEDAS:" << endl;
double moedas[6] = {1, 0.5, 0.25, 0.10, 0.05, 0.01};
for(int i = 0; i < 6; i ++ ){
printf("%d moeda(s) de R$ %.2lf\n", b / int(moedas[i] * 100), moedas[i]);
b %= int(moedas[i] * 100);
}
return 0;
}