- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main(){
- re:
- system("cls");
- cout<<"***智慧找零系統***"<<endl;
- int price,pay,money;
- cout<<"商品價格"<<endl;
- cin>>price;
- cout<<"客人付多少錢"<<endl;
- cin>>pay;
- money=pay-price;
- cout<<"找客人"<<money<<"元"<<endl;
- if(money>=500){
- cout<<money/500<<"張500元鈔票"<<endl;
- money%=500;
- }
- if(money>=100){
- cout<<money/100<<"張100元鈔票"<<endl;
- money%=100;
- }
- if(money>=50){
- cout<<money/50<<"枚50元硬幣"<<endl;
- money%=50;
- }
- if(money>=10){
- cout<<money/10<<"枚10元硬幣"<<endl;
- money%=10;
- }
- if(money>=5){
- cout<<money/5<<"枚5元硬幣"<<endl;
- money%=5;
- }
- if(money>=1){
- cout<<money<<"枚1元硬幣"<<endl;
- }
- system("pause");
- goto re;
- return 0;
- }
複製代碼 |