方法1
分离整数,放大小数 (容易有精度缺失问题)
方法二 乘以100全部变成整数法
#include [HTML_REMOVED]
using namespace std;
int main()
{
double N;
cin >> N;
int a = (int)(100 * N);
int q = a / 10000;
a %= 10000;
int w = a / 5000;
a %= 5000;
int r = a / 2000;
a %= 2000;
int t = a / 1000;
a %= 1000;
int y = a / 500;
a %= 500;
int u = a / 200;
a %= 200;
int i = a / 100;
a %= 100;
int o = a / 50;
a %= 50;
int p = a / 25;
a %= 25;
int s = a / 10;
a %= 10;
int d = a / 5;
a %= 5;
int f = a;
printf("NOTAS:\n%d nota(s) de R$ 100.00\n%d nota(s) de R$ 50.00\n%d nota(s) de R$ 20.00\n%d nota(s) de R$ 10.00\n%d nota(s) de R$ 5.00\n%d nota(s) de R$ 2.00\n", q, w, r, t, y, u);
printf("MOEDAS:\n%d moeda(s) de R$ 1.00\n%d moeda(s) de R$ 0.50\n%d moeda(s) de R$ 0.25\n%d moeda(s) de R$ 0.10\n%d moeda(s) de R$ 0.05\n%d moeda(s) de R$ 0.01\n", i, o, p, s, d, f);
return 0;
}