Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int number = введенное число;
- int[] coins = {50,25,10,5,2,1};
- Map<Integer, Integer> result = new HashMap();
- for (int coin : coins) {
- int count = number / coin;
- number -= count * coin;
- if (count > 0) {
- result.put(coin, count)
- };
- }
Add Comment
Please, Sign In to add comment