Skip to content

Instantly share code, notes, and snippets.

@danielsaad
Created October 18, 2019 14:12
Show Gist options
  • Save danielsaad/cfd225099972046dd4cd17762741bffb to your computer and use it in GitHub Desktop.
Save danielsaad/cfd225099972046dd4cd17762741bffb to your computer and use it in GitHub Desktop.
#include <cstdio>
#include <cmath>
int main(){
double n;
int reais,centavos;
int x;
scanf("%lf",&n);
reais = trunc(n);
centavos = 100*(n - reais);
printf("NOTAS:\n");
x=reais;
printf("%d nota(s) de R$ 100.00\n",x/100);
x %= 100;
printf("%d nota(s) de R$ 50.00\n",x/50);
x %= 50;
printf("%d nota(s) de R$ 20.00\n",x/20);
x %= 20;
printf("%d nota(s) de R$ 10.00\n",x/10);
x %= 10;
printf("%d nota(s) de R$ 5.00\n",x/5);
x %= 5;
printf("%d nota(s) de R$ 2.00\n",x/2);
x %=2;
printf("MOEDAS:\n");
printf("%d moeda(s) de R$ 1.00\n",x);
x = centavos;
printf("%d moeda(s) de R$ 0.50\n",x/50);
x %= 50;
printf("%d moeda(s) de R$ 0.25\n",x/25);
x %= 25;
printf("%d moeda(s) de R$ 0.10\n",x/10);
x %= 10;
printf("%d moeda(s) de R$ 0.05\n",x/5);
x %= 5;
printf("%d moeda(s) de R$ 0.01\n",x);
return(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment