Created
July 25, 2016 02:48
-
-
Save aadimator/701b2586c4f5a9a829112baeb1235816 to your computer and use it in GitHub Desktop.
Changing Money
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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