換錢

 avatar
user_3763047219
c_cpp
2 years ago
455 B
2
Indexable
Never
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>//header standard Input/ouput
#include<stdbool.h>
#include<assert.h>
#include<math.h>

int main()
{
	int num;
	scanf("%d", &num);
	int money[7]{ 1000,500,100,50,10,5,1 };
	int change[7]{};
	for (int i = 0;i < 7;i++) {
		change[i] = num / money[i];
		num = num - money[i] * (num / money[i]);
		if (change[i] > 0) {
			printf("%d:%d\n", money[i], change[i]);
		}
	}
}