返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.         cout<<"***智慧找零系統***"<<endl<<endl;
  7.     int a,s,d,f,g,h,j;
  8.     cout<<"請輸入商品價格: ";
  9.     cin>>a;
  10.     cout<<"客人付了多少錢: ";
  11.     cin>>s;
  12.     cout<<endl;
  13.    
  14.     if(a>s)
  15.     {
  16.             cout<<"錢不夠喔!還差"<<a-s<<"元";
  17.          
  18.         }
  19.       
  20.         else if(a==s)
  21.         {
  22.                 cout<<"剛剛好!謝謝惠顧!";
  23.         }
  24.       
  25.         else if (s>9999)
  26.         {
  27.                 cout<<"錢太多? 全部送我吧!"<<endl;
  28.         }
  29.       
  30.         else
  31.         {
  32.                 d=s-a;
  33.                
  34.                 cout<<"須找客人"<<d<<"元"<<endl<<endl;
  35.       
  36.         j=s-a;
  37.    
  38.     cout<<"500元鈔票"<<j/500<<"張"<<endl;
  39.     d=j%500;
  40.    
  41.     cout<<"100元鈔票"<<d/100<<"張"<<endl;
  42.     f=d%100;
  43.    
  44.     cout<<"50元硬幣"<<f/50<<"枚"<<endl;
  45.     g=f%50;
  46.    
  47.     cout<<"10元硬幣"<<g/10<<"枚"<<endl;
  48.     h=g%10;
  49.    
  50.     cout<<"1元硬幣"<<h/1<<"枚"<<endl;
  51.    
  52.     }
  53.         system("pause");
  54.         return 0;
  55. }
複製代碼

TOP

返回列表