본문 바로가기

Programming/Algorithm

<코드업> 3301 : 거스름돈

#include <stdio.h>
int main() {
	int money, cnt = 0;
	scanf_s("%d", &money);
	while (money >= 50000) {
		money -= 50000; cnt++;
	}
	while (money >= 10000) {
		money -= 10000; cnt++;
	}
	while (money >= 5000) {
		money -= 5000; cnt++;
	}
	while (money >= 1000) {
		money -= 1000; cnt++;
	}
	while (money >= 500) {
		money -= 500; cnt++;
	}
	while (money >= 100) {
		money -= 100; cnt++;
	}
	while (money >= 50) {
		money -= 50; cnt++;
	}
	while (money >= 10) {
		money -= 10; cnt++;
	}
	printf("%d", cnt);
}