Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- size_t count_of_coins(double, double, size_t &);
- int main() {
- double price, coin;
- size_t count = 0;
- cout << "Enter price: ";
- cin >> price;
- cout << "Enter coin: ";
- cin >> coin;
- cout << count_of_coins(price, coin, count) << endl;
- return 0;
- }
- size_t count_of_coins(double price, double coin, size_t &count) {
- if (price <= 0.0)
- return 0;
- else {
- count++;
- count_of_coins(price - coin, coin, count);
- //cout << price << " | " << count << endl; // Debug
- }
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement