Skip to content

Instantly share code, notes, and snippets.

@aadimator
Created July 25, 2016 02:48
Show Gist options
  • Save aadimator/701b2586c4f5a9a829112baeb1235816 to your computer and use it in GitHub Desktop.
Save aadimator/701b2586c4f5a9a829112baeb1235816 to your computer and use it in GitHub Desktop.
Changing Money
#include <iostream>
int get_change(int n) {
int coins[] = {10, 5, 1};
int min = 0;
for (int i = 0; n > 0; i++) {
min += n / coins[i];
n %= coins[i];
}
return min;
}
int main() {
int n;
std::cin >> n;
std::cout << get_change(n) << '\n';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment