Odpowiedź :
Odpowiedź:
#include <iostream>
using namespace std;
int reszta;
int liczba1 = 0;
int liczba2 = 0;
int liczba5 = 0;
int main() {
cout << "Podaj kwotę do wydania: ";
cin >> reszta;
liczba5 = reszta/5;
reszta = reszta - liczba5 * 5;
liczba2 = reszta/2;
liczba1 = reszta = reszta - liczba2 * 2;
cout << endl;
if (liczba5 == 0 && liczba2 == 0 && liczba1 == 0) {
cout << "Brak reszty" << endl;
return 0;
}
cout << "Należy wydac: " << endl;
if (liczba5 > 0) {
cout << liczba5 << " szt. pięciozłotówek," << endl;
}
if (liczba2 > 0) {
cout << liczba2 << " szt. dwuzłotówek," << endl;
}
if (liczba1 > 0) {
cout << liczba1 << " szt. jednozłotówek," << endl;
}
return 0;
}
Wyjaśnienie: