프로그래밍 언어/C언어

CODE GROUND > 연습문제 > 잔돈

B612 2021. 7. 21. 14:15

원래는 파티셰리 문제를 풀 생각이였지만, 마땅한 방법이 생각나지 않았다...ㅠㅠㅠ

그래서 비슷해 보이는 잔돈 문제를 먼저 풀었다

파티셰리 문제 푸는 데 딱히 도움이 되지는 않을 것 같..

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int test;
	int t;
	int ans;
	int a = 0;
	int b = 0;
	int c = 0;
	int d = 0;

	setbuf(stdout, NULL);

	scanf("%d", &t);
	for (test = 0; test < t; test++)
	{
		scanf("%d", &ans);
		for (a = 0; ans > 499; a++)
		{
			ans -= 500;
		}
		for (b = 0; ans > 99; b++)
		{
			ans -= 100;
		}
		for (c = 0; ans > 49; c++)
		{
			ans -= 50;
		}
		d = ans / 10;
		printf("Case #%d\n", test + 1);
		printf("%d %d %d %d\n", d, c, b, a);
	}
	return 0;
}