C/C++の宿題を片付けます 94代目
■ このスレッドは過去ログ倉庫に格納されています
0209名無しさん@そうだ選挙に行こう
2007/07/29(日) 20:01:54#include <stdio.h>
void pay(int price, const int *coins, int index)
{
if (coins[index]) {
printf("%d %dmai\n", coins[index], price / coins[index]);
pay(price % coins[index], coins, index + 1);
}
}
int main(void)
{
int d[] = { 10000, 5000, 2000, 1000, 500, 100, 50, 10, 5, 1, 0 };
unsigned price;
while (scanf("%d", &price) == 1)
pay(price, d, 0);
return 0;
}
■ このスレッドは過去ログ倉庫に格納されています