Untitled
Guest 175 7th May, 2024
#include <iostream>
#include <unordered_map>
using namespace std;
unordered_map<int, int> wydajReszte(float doZaplaty, float otrzymanaKwota) {
unordered_map<int, int> resztaWNominalach;
float reszta = otrzymanaKwota - doZaplaty;
int nominaly[] = {500, 200, 100, 50, 20, 10, 5, 2, 1};
int iloscNominalow;
for (int i = 0; i < sizeof(nominaly) / sizeof(nominaly[0]); i++) {
iloscNominalow = reszta / nominaly[i];
if (iloscNominalow > 0) {
resztaWNominalach[nominaly[i]] = iloscNominalow;
reszta -= iloscNominalow * nominaly[i];
}
}
return resztaWNominalach;
}
int main() {
float doZaplaty, otrzymanaKwota;
cout << "Podaj kwotę do zapłaty: ";
cin >> doZaplaty;
cout << "Podaj kwotę, którą klient podał: ";
cin >> otrzymanaKwota;
unordered_map<int, int> reszta = wydajReszte(doZaplaty, otrzymanaKwota);
cout << "Reszta:" << endl;
for (auto it = reszta.begin(); it != reszta.end(); ++it) {
cout << it->second << " x " << it->first << " PLN" << endl;
}
return 0;
}
To share this paste please copy this url and send to your friends
RAW Paste Data
Recent Pastes
- Подшипники Цены
HTTP Strict-Transport-Security | 6 | 3 hours ago
- Doxycycline And Epiduo For Acne - rrkurqpldh
WebAssembly | 10 | 14 hours ago
- Утепление дома снаружи цена
Git | 11 | 15 hours ago
- Untitled
Markup | 24 | 15 hours ago
- The Wedding Photographer
Scheme | 11 | 16 hours ago
- Снегоуборщик Manner M209 Запчасти
WebAssembly | 10 | 16 hours ago
- Станок Туалетная Бумага Сколько Стоит
Icon | 10 | 17 hours ago