#include<iostream>
using namespace std;
const int SIZE = 5;
int coin[SIZE] = { 100, 50, 10, 5, 1};
int num[SIZE];
int exchange(int n);
int main()
{
using namespace std;
double money;
string name[SIZE] = {"100元", "50元", "10元", "5元", "1元"};
cout << "请输入金额:";
cin >> money;
int n = (int)(money);
exchange(n);
for(int i=0; i<SIZE; i++)
{
cout << name[i] << "币种: " << num[i] << " 张\n";
}
return 0;
}
int exchange(int n)
{
int i;
for (i=0; i<SIZE; i++)
if (n >= coin[i]) break;
while (n>0 && i<SIZE)
{
if(n >= coin[i])
{
n -= coin[i];
num[i]++;
}else if(n<10 && n>=5)
{
num[SIZE-1]++;
break;
}else i++;
}
return 0;
}