本帖最後由 鎧言 於 2013-6-9 22:03 編輯
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int price, pay, money;
- cout<<"***鎧言發明的超智慧找零系統***"<<endl;
- cout<<"***歡迎光臨***"<<endl;
- cout<<"***本商場購物滿1000元,打八折;滿500元享九折優惠***"<<endl;
- cout<<"請輸入商品原價:";
- cin>>price;
- if(price>=1000)
- {
- price=price*0.8;
- }else if(price>=500)
- {
- price=price*0.9;
- }else
- {
- price=price;
- }
- cout<<"請輸入客人付了多少錢: ";
- cin>>pay;
- money = pay-price;
- if(money==0)
- {
- cout<<"錢剛剛好! 請慢走!"<<endl;
- }
- if(money<0)
- {
- cout<<"錢不夠! 還欠"<<-money<<"元"<<endl;
- }
- if(money>0)
- {
- cout<<"總共需要找客人"<<money<<"元";
- if(money>=500)
- {
- cout<<"500元鈔票"<<money/500<<"張"<<endl;
- money=money%500;
- }
- if(money>=100)
- {
- cout<<"100元鈔票"<<money/100<<"張"<<endl;
- money=money%100;
- }
- if(money>=50)
- {
- cout<<"50元硬幣"<<money/50<<"枚"<<endl;
- money=money%50;
- }
- if(money>=10)
- {
- cout<<"10元硬幣"<<money/10<<"枚"<<endl;
- money=money%10;
- }
- if(money>=5)
- {
- cout<<"5元硬幣"<<money/5<<"枚"<<endl;
- money=money%5;
- }
- if(money>=1)
- {
- cout<<"1元硬幣"<<money/1<<"枚"<<endl;
- money=money%1;
- }
- cout<<"謝謝!感謝您的光臨!"<<endl;
- }
- system("pause");
- return 0;
- }
複製代碼 |