返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main ()
  5. {     
  6.    int total,cm,givingmoney;
  7.    cout<<"***intelligent money-giving machine***"<<endl;
  8.    cout<<"the purchase cost:"<<endl;   
  9.    cin>>total;
  10.    cout<<"customers shell out:"<<endl;
  11.    cin>>cm;   
  12.    givingmoney=cm-total;  
  13.    cout<<"you need to give: "<<givingmoney<<endl;
  14.    if(givingmoney>=500)
  15.    {
  16.     cout<<"500 dollar bills: "<<givingmoney/500<<" piece"<<endl;
  17.     givingmoney=givingmoney%500;                     
  18.    } if(givingmoney>=100)
  19.    {
  20.     cout<<"100 dollar bills: "<<givingmoney/100<<" piece"<<endl;
  21.     givingmoney=givingmoney%100;                     
  22.    } if(givingmoney>=50)
  23.    {
  24.     cout<<"50 dollar coin: "<<givingmoney/50<<" cookie"<<endl;
  25.     givingmoney=givingmoney%50;                     
  26.    } if(givingmoney>=10)
  27.    {
  28.     cout<<"10 dollar coin: "<<givingmoney/10<<" cookie"<<endl;
  29.     givingmoney=givingmoney%10;                     
  30.    }if(givingmoney>=5)
  31.    {
  32.     cout<<"5 dollar coin: "<<givingmoney/5<<" cookie"<<endl;
  33.     givingmoney=givingmoney%5;                     
  34.    }if(givingmoney>=1)
  35.    {
  36.     cout<<"1 dollar coin: "<<givingmoney/1<<" cookie"<<endl;
  37.     givingmoney=givingmoney%1;                     
  38.    }
  39.    
  40.    system("pause");
  41.    return 0;
  42. }
複製代碼

TOP

返回列表