- #include<cstdlib>
- using namespace std;
- int main()
- {
-
- int pay=0;
- int price=0;
- int Flash=0;
- int Q=0;
- int W=0;
- int E=0;
- int R=0;
- cout << "商品價格:"<< endl;
- cin>>price;
- cout << "支付的錢:"<< endl;
- cin>>pay;
- Flash=pay-price;
- if(Flash>=500)
- {
- Q=Flash/500;
- int TP=Flash%500;
- Flash=TP;
- }
- if(Flash>=100)
- {
- W=Flash/100;
- int TP=Flash%100;
- Flash=TP;
- }
- if(Flash>=50)
- {
- E=Flash/50;
- int TP=Flash%50;
- Flash=TP;
- }
- if(Flash>=10)
- {
- R=Flash/10;
- int TP=Flash%10;
- Flash=TP;
- }
- cout << " 總共需找客人" << pay-price << endl;
- cout << "500元鈔票" << Q << "張" << endl;
- cout << "100元鈔票" << W << "張" << endl;
- cout << "50元硬幣" << E << "枚" << endl;
- cout << "10元硬幣" << R << "枚" << endl;
-
- system("pause");
- return 0;
- }
複製代碼 |