URI ONLINE JUDGE SOLUTION 1021 - Banknotes and Coins
Problem
#include<stdio.h>
int main()
{
int c[12],n,f,i,num[] = {100,50,20,10,5,2,100,50,25,10,5,1};
double x;
scanf("%lf",&x);
n = x;
f = x*100;
f = f%100;
printf("NOTAS:\n");
for(i = 0;i<6;i++)
{
c[i] = n/num[i];
n = n%num[i];
printf("%d nota(s) de R$ %d.00\n", c[i], num[i]);
}
if(n == 1)
f = f+100;
printf("MOEDAS:\n");
for(i = 6;i<12;i++)
{
c[i] = f/num[i];
f = f%num[i];
printf("%d moeda(s) de R$ %0.2lf\n", c[i], num[i]/100.0);
}
return 0;
}
Read a value of floating point with two decimal places. This represents
a monetary value. After this, calculate the smallest possible number of
notes and coins on which the value can be
decomposed. The considered notes are of 100, 50, 20, 10, 5, 2. The
possible coins are of 1, 0.50, 0.25, 0.10, 0.05 and 0.01. Print the
message “NOTAS:” followed by the list of notes and the message “MOEDAS:”
followed by the list of coins.
Input
The input file contains a value of floating point N (0 ≤ N ≤ 1000000.00).
Output
Print the minimum quantity of banknotes and coins necessary to change the initial value, as the given example.
Solution#include<stdio.h>
int main()
{
int c[12],n,f,i,num[] = {100,50,20,10,5,2,100,50,25,10,5,1};
double x;
scanf("%lf",&x);
n = x;
f = x*100;
f = f%100;
printf("NOTAS:\n");
for(i = 0;i<6;i++)
{
c[i] = n/num[i];
n = n%num[i];
printf("%d nota(s) de R$ %d.00\n", c[i], num[i]);
}
if(n == 1)
f = f+100;
printf("MOEDAS:\n");
for(i = 6;i<12;i++)
{
c[i] = f/num[i];
f = f%num[i];
printf("%d moeda(s) de R$ %0.2lf\n", c[i], num[i]/100.0);
}
return 0;
}
OniasiYconcreTopeka Samantha Peoples https://marketplace.visualstudio.com/items?itemName=9cemasalho.Gil-s-Lucid-Dreams-gratuita
ReplyDeletepcanacakor
Yrevul0prod_ka_1998 Randy Glasper https://www.lubylara.com.br/profile/Heroesiiicompletewog358f/profile
ReplyDeletesiolearfoge
patiQgin Angie White Here
ReplyDeletesigcevenli
Ygaeplecinsu Novi Roberts download
ReplyDeleteclick here
click
click
touchsraffgimar
utacZconso Darrell Oakland That
ReplyDeleteClick here
Check
cioglycarston
procomVtorra Mai Miller Microsoft Word 2021
ReplyDeleteThat
VMware Workstation
WiFi Analyzer
pibottwetre