返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6. cout<<"*** 智慧找零系統 ***"<<endl;
  7. re:
  8.     int a,b;
  9.     cout<<"商品價格:";
  10.     cin>>a;
  11.     cout<<"客人付了多少錢:";
  12.     cin>>b;
  13.     int c=b-a;
  14.     cout<<endl;
  15.     cout<<"需找給客人"<<c<<"元"<<endl;
  16.     cout<<endl;
  17.     cout<<"1000元鈔票找"<<c/1000<<"張"<<endl;
  18.     c=c%1000;
  19.     cout<<"500元鈔票找"<<c/500<<"張"<<endl;
  20.     c=c%500;
  21.     cout<<"100元鈔票找"<<c/100<<"張"<<endl;
  22.     c=c%100;
  23.     cout<<"50元銅板找"<<c/50<<"個"<<endl;
  24.     c=c%50;
  25.     cout<<"10元銅板找"<<c/10<<"個"<<endl;
  26.     c=c%10;
  27.     cout<<"5元銅板找"<<c/5<<"個"<<endl;
  28.     c=c%5;
  29.     cout<<"1元銅板找"<<c/1<<"個"<<endl;
  30.     cout<<endl;
  31.     goto re;
  32.     system("pause");
  33.     return 0;
  34. }
複製代碼

TOP

返回列表