- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- cout<<"***智慧找零系統***"<<endl<<endl;
- int a,s,d,f,g,h,j;
- cout<<"請輸入商品價格: ";
- cin>>a;
- cout<<"客人付了多少錢: ";
- cin>>s;
- cout<<endl;
-
- if(a>s)
- {
- cout<<"錢不夠喔!還差"<<a-s<<"元";
-
- }
-
- else if(a==s)
- {
- cout<<"剛剛好!謝謝惠顧!";
- }
-
- else if (s>9999)
- {
- cout<<"錢太多? 全部送我吧!"<<endl;
- }
-
- else
- {
- d=s-a;
-
- cout<<"須找客人"<<d<<"元"<<endl<<endl;
-
- j=s-a;
-
- cout<<"500元鈔票"<<j/500<<"張"<<endl;
- d=j%500;
-
- cout<<"100元鈔票"<<d/100<<"張"<<endl;
- f=d%100;
-
- cout<<"50元硬幣"<<f/50<<"枚"<<endl;
- g=f%50;
-
- cout<<"10元硬幣"<<g/10<<"枚"<<endl;
- h=g%10;
-
- cout<<"1元硬幣"<<h/1<<"枚"<<endl;
-
- }
- system("pause");
- return 0;
- }
複製代碼 |