Solution of URI 1018::Banknotes
Before seeing the solution make sure that you have tried enough. Don’t copy the whole code, just find out the logic. If you feel any problem, you will inform me by comment.
#include <stdio.h>
int main()
{
long int
N,T;
int
n100,n50,n20,n10,n5,n2,n1;
scanf("%ld",&N);
T=N;
n100=N/100;
N=N-(n100*100);
n50=N/50;
N=N-(n50*50);
n20=N/20;
N=N-(n20*20);
n10=N/10;
N=N-(n10*10);
n5=N/5;
N=N-(n5*5);
n2=N/2;
N=N-(n2*2);
n1=
N/1;
N=N-(n1*1);
printf("%ld\n",T);
printf("%d nota(s) de R$ 100,00\n",n100);
printf("%d nota(s) de R$ 50,00\n",n50);
printf("%d nota(s) de R$ 20,00\n",n20);
printf("%d nota(s) de R$ 10,00\n",n10);
printf("%d nota(s) de R$ 5,00\n",n5);
printf("%d nota(s) de R$ 2,00\n",n2);
printf("%d nota(s) de R$ 1,00\n",n1);
return 0;
}
No comments