返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.        
  7.         int a, b,c;
  8.         cout<<"請輸入商品價格:";
  9.         cin>>a;
  10.         cout<<"你付多少:";
  11.         cin>>b;
  12.         c=b-a;
  13.         cout<<"總共需找客人:"<<c<<"元"<<endl;
  14.         if(c>500){
  15.                 cout<<"500元鈔票"<<c/500<<"張"<<endl;
  16.         }
  17.         c -= c/500*500;
  18.         if(c>100){
  19.                 cout<<"100元鈔票"<<c/100<<"張"<<endl;
  20.         }
  21.         c -= c/100*100;
  22.         if(c>50){
  23.                 cout<<"50元硬幣"<<c/50<<"枚"<<endl;
  24.         }  
  25.         c -= c/50*50;
  26.         if(c>10){
  27.                 cout<<"10元硬幣"<<c/10<<"枚"<<endl;
  28.         }  
  29.        
  30.    system ("pause");
  31.    return 0;
  32. }
複製代碼

TOP

返回列表