返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main (){
  5.     int x,y,z;
  6. cout<<"***智慧找零系統***"<<endl;
  7. re:
  8. cout<<"請輸入商品價格";
  9. cin>>x;
  10. cout<<"客人付了多少?";
  11. cin>>y;
  12. z=y-x;
  13. cout<<"需要找客人"<<z<<"元"<<endl;
  14. {
  15. if(z>=500)
  16.         cout<<"500元鈔票"<<z/500<<"張"<<endl;
  17. z%=500;
  18. if (z<500&&z>=100)
  19.         cout<<"100元鈔票"<<z/500<<"張"<<endl;
  20. z%=100;
  21. if(z>=50&&z<100)
  22. cout<<"50元硬幣"<<z/50<<"個"<<endl;
  23. z%=50;
  24. if(z>=10&&z<50)
  25. cout<<"10元硬幣"<<z/10<<"個"<<endl;
  26. z%=10;
  27. if(z>=5&&z<10)
  28. cout<<"5元硬幣"<<z/5<<"個"<<endl;
  29. z%=5;
  30. if(z>=1&&z<5)
  31. cout<<"1元硬幣"<<z/1<<"個"<<endl;
  32. z%=1;

  33. }
  34. cout<<endl;
  35. goto re;


  36. system("pause");
  37. return 0;

  38. }
複製代碼

TOP

返回列表