返回列表 發帖
  1. #include<cstdlib>
  2. using namespace std;
  3. int main()
  4. {     
  5.      
  6.      int pay=0;
  7.      int price=0;
  8.      int Flash=0;
  9.      int Q=0;
  10.      int W=0;
  11.      int E=0;
  12.      int R=0;
  13.      cout << "商品價格:"<< endl;
  14.      cin>>price;
  15.      cout << "支付的錢:"<< endl;
  16.      cin>>pay;
  17.      Flash=pay-price;
  18.      if(Flash>=500)
  19.       {
  20.         Q=Flash/500;
  21.         int TP=Flash%500;
  22.         Flash=TP;
  23.       }
  24.       if(Flash>=100)
  25.       {
  26.         W=Flash/100;
  27.         int TP=Flash%100;
  28.         Flash=TP;
  29.       }
  30.       if(Flash>=50)
  31.       {
  32.         E=Flash/50;
  33.         int TP=Flash%50;
  34.         Flash=TP;
  35.       }
  36.       if(Flash>=10)
  37.       {  
  38.         R=Flash/10;
  39.         int TP=Flash%10;
  40.         Flash=TP;
  41.       }
  42.      cout << " 總共需找客人" << pay-price << endl;
  43.      cout << "500元鈔票"   <<  Q << "張" << endl;
  44.      cout << "100元鈔票"   <<  W << "張" << endl;
  45.      cout << "50元硬幣"   <<  E << "枚" << endl;
  46.      cout << "10元硬幣"   <<  R << "枚" << endl;
  47.    
  48.      system("pause");
  49.      return 0;
  50. }
複製代碼

TOP

返回列表