관리 메뉴

cyphen156

백준-일반 수학 1 2720 세탁소 사장 동혁 본문

컴퓨터공학/알고리듬 풀이

백준-일반 수학 1 2720 세탁소 사장 동혁

cyphen156 2025. 2. 10. 12:24

세탁소 사장 동혁

거스름 돈 계산기

제약사항

  • Test T
  • 0 < Max Val <= 5.00$ ==> 0 < Cent <= 500
  • Quarter : 0.25$
  • Dime : 0.1$
  • Nickel : 0.05$
  • Penny : 0.01$
  • 받는 동전의 개수를 최소로 

주의 사항

테스트 케이스 조건에 의해 거스름 돈이 0인 경우는 없다.

CPP풀이

세탁소 사장 동혁_2720.cpp

/**
 * 백준 세탁소 사장 동혁_2720
 * 거스름 돈 계산기
 * 
 * 제한사항
 *******************************************
 * Test T                                  *
 * 0 < Max Val <= 5.00$ ==> 0 < Cent <= 500*
 * Quarter : 0.25$                         *
 * Dime : 0.1$                             *
 * Nickel : 0.05                           *
 * Penny : 0.01$                           *
 * 받는 동전의 개수를 최소로                 *
 *******************************************
 *
 *
 *
 * 주의
 * 테스트 케이스 조건에 의해 거스름 돈이 0인 경우는 없다.
 * 
 * 풀이시간 20분
 */

#include <iostream>

using namespace std;

int main(void)
{
    // T = TestCastCnt
    int T = 0;
    int divideValues[4] = { 25, 10, 5, 1 };
  

    cin >> T;

    for (int i = 0; i < T; ++i)
    {
        int inputValue;
        cin >> inputValue;
        int rtnValues[4] = { 0 };

        for (int j = 0; j < size(divideValues); ++j)
        {
            int temp = inputValue / divideValues[j];
            inputValue %= divideValues[j];
            rtnValues[j] = temp;
            cout << rtnValues[j] << " ";
        }    

        cout << endl;
    }

    
    return 0;
}

모든 예제 코드의 소스파일은 제 개인 깃허브 레포지토리 에 있습니다.

 

Workspace/알고리듬 풀이 at main · cyphen156/Workspace

Studying . Contribute to cyphen156/Workspace development by creating an account on GitHub.

github.com