슈콩

COS PRO 1급 JAVA 거스름돈 구하기 본문

카테고리 없음

COS PRO 1급 JAVA 거스름돈 구하기

shukong 2025. 12. 11. 23:07

 

 

[소스 코드]

class Main {
    public int solution(int money) {
        int coin[] = {10, 50, 100, 500, 1000, 5000, 10000, 50000};
        int counter = 0;
        int idx = coin.length - 1;
        while (money > 0){
            counter += money / coin[idx];
            money %= coin[idx];
            idx -= 1;
        }
        return counter;
    }
}