#include<iostream>
using namespace std;

int main(void)
{
    char st;
    char ch='y';
    int pay,a,b,c,d,e,f,g,h,i,j,k;
    int total = 0;
    float z;
    do
    {
        cout<<"買";
        cin>>z;
        if(z>=900)
            z=z*0.8;
        else if (z>=500)
            z=z*0.9;
        else
            z=z*0.95;

        total = total + z;

        cout<<"繼續??(y/n)";
        cin>>ch;
    }
    while(ch=='y');

    cout<<"應付金額"<<z<<endl;
    cout<<"付";
    cin>>pay;
    a=pay-total;
    if (a<0)
        cout<<"錯誤 \n";
    else
    {
        b=a/500;
        c=a%500;
        d=c/100;
        e=c%100;
        f=e/50;
        g=e%50;
        h=g/10;
        i=g%10;
        j=i/5;
        k=i%5;
        cout<<"找零="<<a<<endl;
        cout<<"500*"<<b<<endl<<"100*"<<d<<endl<<"50*"<<f<<endl<<"10*"<<h<<endl
            <<"5*"<<j<<endl<<"1*"<<k<<endl;
    }
    cin>>st;
}
