本帖最後由 t8155745 於 2012-3-17 17:25 編輯
- [code][code]#include <iostream>
- using namespace std;
- int main()
- {
- int price,money;
- cout<<"%%%智慧錢找零機%%%"<<endl;
- cout<<"請輸入商品價格:";
- cin>>price;
- cout<<"請輸入客人付了多少錢:";
- cin>>money;
- cout<<"需找客人:"<<money-price<<"元"<<endl;
- money=money-price;
- int a,b,c,d,e;
- if(money>=500)
- {
- a=money/500;
- money=money%500;
- cout<<"500元鈔票"<<a<<"張, " ;
- }
- if(money>=100)
- {
- b=money/100;
- money=money%100;
- cout<<"100鈔票"<<b<<"張, ";
- }
- if(money>=50)
- {
- c=money/50;
- money=money%50;
- cout<<"50硬幣"<<c<<"張, ";
- }
- if(money>=10)
- {
- d=money/10;
- money=money%10;
- cout<<"10硬幣"<<d<<"枚, ";
- }
- if(money>=5)
- {
- e=money/5;
- money=money%5;
- cout<<"5硬幣"<<e<<"枚, ";
- }
- if(money>=1)
- {
-
- cout<<"1硬幣"<<money<<"枚, ";
- } system("pause");
- return 0;
- }
複製代碼 [/code][/code] |