Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- double notes[] = {100.00, 50.00, 20.00, 10.00, 5.00, 2.00};
- double coins[] = {100, 50, 25, 10, 5, 1};
- double money;
- cin >> money;
- int whole = money;
- cout << "NOTAS:" << endl;
- for(int i = 0; i < sizeof(notes)/(sizeof(double)); i++){
- int n = whole/(int)(notes[i]);
- cout << n << " nota(s) de R$ " << fixed << setprecision(2) << notes[i] << endl;
- whole = whole%(int)notes[i];
- }
- int decimal = whole*100 + ((money*100) - ((int)money)*100);
- cout << "MOEDAS:" << endl;
- for(int i = 0; i < sizeof(coins)/sizeof(double); i++){
- int n = (int)decimal/(int)coins[i];
- cout << n << " moeda(s) de R$ " << fixed << setprecision(2) << coins[i]/100.00 << endl;
- decimal = decimal%(int)coins[i];
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment