被精度困扰一个多小时,好家伙
#include <bits/stdc++.h>
using namespace std;
const int N=12;
vector<double> money{100.0,50.0,20.0,10.0,5.0,2.0,1.0,0.5,0.25,0.10,0.05,0.01};
int flag[N];
int main()
{
double n;
cin>>n;
for(int i=0;i<N;i++)
{
flag[i]=n/money[i];
n=n-flag[i]*money[i]+0.000001;//精度丢失处理
}
printf("NOTAS:\n");
for(int i=0;i<N/2;i++)
{
printf("%d nota(s) de R$ %.2f\n",flag[i],money[i]);
}
printf("MOEDAS:\n");
for(int i=N/2;i<N;i++)
{
printf("%d moeda(s) de R$ %.2f\n",flag[i],money[i]);
}
return 0;
}