C/c언어 수업
동전교환기
by sj0020
2020. 7. 31.
#include <stdio.h>
void main(void) {
int a = 0; //500원
int b = 0; //100
int c = 0; //50
int d = 0; //10
int money = 0;
printf("how much?");
scanf("%d",&money);
a = money / 500;
b = (money - (a * 500)) / 100;
c = (money - (a * 500) - (b * 100)) / 50;
d = (money - (a * 500) - (b * 100) - (c * 50)) / 10;
printf("----\n동전교환\n----\n");
printf("500: %d\n", a);
printf("100: %d\n", b);
printf("50: %d\n", c);
printf("10: %d\n", d);
printf("change: %d", money - (a * 500) - (b * 100) - (c * 50) - (d * 10));
}