Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <array>
- #include "conio.h"
- using namespace std;
- array<int, 12> bankovky = { 5000, 2000, 1000, 500, 200, 100, 50, 20, 10, 5, 2, 1 };
- array<int, 12> pocet;
- array<int, 12> vycetka(int castka, array<int, 12> bankovky);
- int main(void)
- {
- cout << "Castka: ";
- string castka;
- try {
- cin >> castka;
- } catch (int e) {
- return 0;
- }
- cout << endl << "Vysledek: " << endl;
- pocet = vycetka (atoi (castka.c_str()), bankovky);
- for (int i = 0; i < pocet.size(); i++)
- {
- if (pocet[i] != 0)
- cout << pocet[i] << "x " << bankovky[i] << " Kc" << endl;
- }
- _getch();
- return 0;
- }
- array<int, 12> vycetka(int castka, array<int, 12> bankovky)
- {
- array<int, 12> pocet;
- for (int i = 0; i < bankovky.size(); i++)
- {
- pocet[i] = castka / bankovky[i];
- castka = castka % bankovky[i];
- }
- return pocet;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement