-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathbanknotes_and_coins.cpp
92 lines (72 loc) · 1.69 KB
/
banknotes_and_coins.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// https://www.urionlinejudge.com.br/judge/en/problems/view/1021
#include <iostream>
using namespace std;
int main() {
float total;
int cem=0, cinquenta=0, vinte=0, dez=0, cinco=0, dois=0, um=0;
int cinquenta_centavos=0, vinte_e_cinco_centavos=0, dez_centavos=0, cinco_centavos=0, um_centavos=0;
cin >> total;
while (total >= 100) {
total -= 100;
cem++;
}
while (total >= 50) {
total -= 50;
cinquenta++;
}
while (total >= 20) {
total -= 20;
vinte++;
}
while (total >= 10) {
total -= 10;
dez++;
}
while (total >= 5) {
total -= 5;
cinco++;
}
while (total >= 2) {
total -= 2;
dois++;
}
while (total >= 1) {
total -= 1;
um++;
}
while (total >= 0.5) {
total -= 0.50;
cinquenta_centavos++;
}
while (total >= 0.25) {
total -= 0.25;
vinte_e_cinco_centavos++;
}
while (total >= 0.10) {
total -= 0.10;
dez_centavos++;
}
while (total >= 0.05) {
total -= 0.05;
cinco_centavos++;
}
while (total >= 0.01) {
total -= 0.01;
um_centavos++;
}
cout << "NOTAS:" << endl;
cout << cem << " nota(s) de R$ 100.00" << endl;
cout << cinquenta << " nota(s) de R$ 50.00" << endl;
cout << vinte << " nota(s) de R$ 20.00" << endl;
cout << dez << " nota(s) de R$ 10.00" << endl;
cout << cinco << " nota(s) de R$ 5.00" << endl;
cout << dois << " nota(s) de R$ 2.00" << endl;
cout << "MOEDAS:" << endl;
cout << um << " moeda(s) de R$ 1.00" << endl;
cout << cinco_centavos << " moeda(s) de R$ 0.50" << endl;
cout << vinte_e_cinco_centavos << " moeda(s) de R$ 0.25" << endl;
cout << dez_centavos << " moeda(s) de R$ 0.10" << endl;
cout << cinco_centavos << " moeda(s) de R$ 0.05" << endl;
cout << um_centavos << " moeda(s) de R$ 0.01" << endl;
return 0;
}