Zadanie z informatyki cpp:
Napisz procedurę bankomat(kwota).
Bankomat wydaje jedynie banknoty (10, 20, 50, 100, 200, 500).
Podajemy kwotę do wypłacenia, a jeżeli nie da się jej wypłacić w nominałach wyświetlamy błąd.
W wyniku otrzymujemy ilość banknotów poszczególnych nominałów.
UWAGA: Jeśli dany nominał nie jest wypłacany, nie pokazuje się w wynikach!


Odpowiedź :

#include <iostream>

using namespace std;

void bankomat(int kwota)

{

int ile,reszta;

reszta=kwota;

if (reszta%10==0)

{

ile=reszta/500;

if (ile!=0) cout << ile << " : 500" << endl;

reszta=reszta-ile*500;

ile=reszta/200;

if (ile!=0) cout << ile << " : 200" << endl;

reszta=reszta-ile*200;

ile=reszta/100;

if (ile!=0) cout << ile << " : 100" << endl;

reszta=reszta-ile*100;

ile=reszta/100;

if (ile!=0) cout << ile << " : 100" << endl;

reszta=reszta-ile*100;

ile=reszta/50;

if (ile!=0) cout << ile << " : 50" << endl;

reszta=reszta-ile*50;

ile=reszta/50;

if (ile!=0) cout << ile << " : 50" << endl;

reszta=reszta-ile*50;

ile=reszta/20;

if (ile!=0) cout << ile << " : 20" << endl;

reszta=reszta-ile*20;

ile=reszta/20;

if (ile!=0) cout << ile << " : 20" << endl;

reszta=reszta-ile*20;

ile=reszta/10;

if (ile!=0) cout << ile << " : 10" << endl;

reszta=reszta-ile*10;

ile=reszta/10;

}

else cout << "Brak mozliwosci wyplaty" << endl;

}

int main ()

{

int wartosc;

cout << "Podaj kwote: ";

cin >> wartosc;

bankomat(wartosc);

return 0;

}