標題:
智慧找零系統 (二)
[打印本頁]
作者:
葉桔良
時間:
2022-4-16 16:28
標題:
智慧找零系統 (二)
本帖最後由 鄭繼威 於 2022-4-23 15:27 編輯
設計一個更聰明的智慧找零系統, 包括客人付的錢
不足
,
剛好
, 或
任何
可能發生的狀況.
作者:
葉桔良
時間:
2022-4-16 16:28
本帖最後由 鄭繼威 於 2022-4-23 15:29 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int price,pay,money;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
if(price<=0)
goto re;
cout<<"客人付了多少錢: ";
cin>>pay;
if(pay<0)
goto re;
money=pay-price;
if(money==0)
{
cout<<endl<<"剛剛好!銘謝惠顧!"<<endl;
}else if(money<0)
{
cout<<endl<<"錢不夠喔!還差"<<-money<<"元!"<<endl;
}else if(money>=1000)
{
cout<<endl<<"錢太多?全部送我吧!"<<endl;
}else
{
cout<<endl<<"需找客人"<<money<<"元"<<endl<<endl;
if(money>=500)
{
cout<<"五百元鈔票"<<money/500<<"張"<<endl;
money%=500; //money=money%500;
}
if(money>=100)
{
cout<<"一百元鈔票"<<money/100<<"張"<<endl;
money%=100;
}
if(money>=50)
{
cout<<"五十元硬幣"<<money/50<<"枚"<<endl;
money%=50;
}
if(money>=10)
{
cout<<"十元硬幣"<<money/10<<"枚"<<endl;
money%=10;
}
if(money>=5)
{
cout<<"五元硬幣"<<money/5<<"枚"<<endl;
money%=5;
}
if(money>0)
cout<<"一元硬幣"<<money<<"枚"<<endl;
}
cout<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
郭閎宇
時間:
2022-4-16 16:39
本帖最後由 郭閎宇 於 2022-4-16 17:17 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int price,pay,money;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"客人付了多少錢: ";
cin>>pay;
money=pay-price;
if(pay>price)
{
cout<<endl<<"需找客人"<<money<<"元"<<endl<<endl;
if(money>=500)
{
cout<<"五百元鈔票"<<money/500<<"張"<<endl;
money%=500; //money=money%500;
}
if(money>=100)
{
cout<<"一百元鈔票"<<money/100<<"張"<<endl;
money%=100;
}
if(money>=50)
{
cout<<"五十元硬幣"<<money/50<<"枚"<<endl;
money%=50;
}
if(money>=10)
{
cout<<"十元硬幣"<<money/10<<"枚"<<endl;
money%=10;
}
if(money>=5)
{
cout<<"五元硬幣"<<money/5<<"枚"<<endl;
money%=5;
}
if(money>0)
cout<<"一元硬幣"<<money<<"枚"<<endl;
cout<<endl;
}
if(price>pay)
cout<<"錢不夠喔!還差"<<price-pay<<"元"<<endl;
cout<<endl;
if(price==pay)
cout<<"剛剛好!謝謝惠顧"<<endl;
cout<<endl;
if(money>10000)
cout<<"錢太多?全部送我吧"<<endl;
cout<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
許浩浩
時間:
2022-4-16 16:44
本帖最後由 許浩浩 於 2022-4-16 16:55 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
int a, b, c;
cout<<"***智慧找零系統***"<<endl<<endl;
cout<<"請輸入商品價格:"<<endl;
cin>>a;
cout<<"客人付了多少錢:";
cin>>b;
cout<<endl;
c=b-a;
{
if(a<1000 && b>1000)
cout<<"錢太多? 全部送我吧!"<<endl;
else if(b<a)
cout<<"錢不夠喔! 還差"<<a-b<<"元"<<endl;
else if(b>a)
cout<<"需找客人"<<c<<"元"<<endl;
else if(b==a)
cout<<"剛剛好! 銘謝惠顧!"<<endl;
if(c>500){
cout<<"五百元鈔票"<<c/500<<"張"<<endl;
c=c%500;
}
if(c>100){
cout<<"一百元鈔票"<<c/100<<"張"<<endl;
c=c%100;
}
if(c>50){
cout<<"五十元硬幣"<<c/500<<"枚"<<endl;
c=c%50;}
if(c>10){
cout<<"十元硬幣"<<c/10<<"枚"<<endl;
c=c%10;}
if(c>1){
cout<<"一元硬幣"<<c/1<<"枚"<<endl;
c=c%1;}
}
goto re;
system("pause");
return 0;
}
複製代碼
作者:
謝閔丞
時間:
2022-4-16 16:45
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int a,b,c;
cout<<"***智慧找零系統***"<<endl;
cout<<"請輸入商品價格:";
cin>>a;
cout<<"客人給的錢:";
cin>>b;
c=b-a;
if(c>=1&&c<=9999){
cout<<"需給客人"<<c<<"元"<<endl;
}
if(c>=500){
cout<<"五百元鈔票"<<c/500<<"張"<< endl;
c=c%500;
}
if(c>=100){
cout<<"一百元鈔票"<<c/100<<"張"<< endl;
c=c%100;
}
if(c>=50){
cout<<"五十元硬幣"<<c/50<<"枚"<< endl;
c=c%50;
}
if(c>=10){
cout<<"十元硬幣"<<c/10<<"枚"<< endl;
c=c%10;
}
if(c>=1){
cout<<"一元硬幣"<<c<<"枚"<< endl;
}
if(c==0){
cout<<"剛剛好"<< endl;
}
if(c<0){
cout<<"太少了,還要"<<a-b<<"元"<< endl;
}
if(c>=10000){
cout<<"錢太多?"<< endl;
}
system("pause");
return 0;
}
複製代碼
作者:
連翊恩
時間:
2022-4-16 16:46
本帖最後由 連翊恩 於 2022-4-16 17:13 編輯
[code#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
system("cls");
int price,pay,money;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"客人付了多少錢: ";
cin>>pay;
money=pay-price;
{
if(price==pay)
{
cout<<"剛剛好,銘謝惠顧"<<endl;
}
if(price<pay)
{
cout<<"錢還不夠,還差"<<money<<"元"<<endl;
}
if(pay>1000)
{
cout<<"錢太多,全送我吧"<<endl;
}
else{
cout<<endl<<"需找客人"<<money<<"元"<<endl<<endl;
if(money>=500)
cout<<"五百元鈔票"<<money/500<<"張"<<endl;
money%=500;
}
if(money>=100)
{
cout<<"一百元鈔票"<<money/100<<"張"<<endl;
money%=100;
}
if(money>=50)
{
cout<<"五十元硬幣"<<money/50<<"枚"<<endl;
money%=50;
}
if(money>=10)
{
cout<<"十元硬幣"<<money/10<<"枚"<<endl;
money%=10;
}
if(money>=5)
{
cout<<"五元硬幣"<<money/5<<"枚"<<endl;
money%=5;
}
if(money>0)
{ cout<<"一元硬幣"<<money<<"枚"<<endl;
cout<<endl;
}
}
system("pause");
return 0;
}
作者:
侯宣任
時間:
2022-4-16 16:58
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
int price,pay,money;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"客人付了多少錢: ";
cin>>pay;
money=pay-price;
if(pay==price)
cout<<"剛剛好! 謝謝惠顧!";
if(pay<price)
cout<<"錢不夠! 還差"<<money<<"元!";
if(pay>price)
cout<<"錢太多! 全送我吧!";
else{
cout<<endl<<"需找客人"<<money<<"元"<<endl<<endl;
if(money>=500)
{
cout<<"五百元鈔票"<<money/500<<"張"<<endl;
money%=500; //money=money%500;
}
if(money>=100)
{
cout<<"一百元鈔票"<<money/100<<"張"<<endl;
money%=100;
}
if(money>=50)
{
cout<<"五十元硬幣"<<money/50<<"枚"<<endl;
money%=50;
}
if(money>=10)
{
cout<<"十元硬幣"<<money/10<<"枚"<<endl;
money%=10;
}
if(money>=5)
{
cout<<"五元硬幣"<<money/5<<"枚"<<endl;
money%=5;
}
if(money>0)
cout<<"一元硬幣"<<money<<"枚"<<endl;
}
cout<<endl;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
黃昱琁
時間:
2022-4-16 17:14
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int p=0,c=0,m=0;
cout<<"***智慧找零系統***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>p;
cout<<"客人付了多少錢: ";
cin>>c;
m=c-p;
if(p==c)
cout<<"剛剛好! 銘謝惠顧"<<endl;
else if(c<p)
cout<<"錢不夠喔! 還差"<<p-c<<"元"<<endl;
else if(c>1000)
cout<<"錢太多! 全部送我吧!"<<endl;
else{
cout<<"須找客人"<<m<<"元"<<endl<<endl;
if(m>=500)
cout<<"五百元鈔票"<<m/500<<"張"<<endl;
m=m%500;
if(m>=100)
cout<<"一百元鈔票"<<m/100<<"張"<<endl;
m=m%100;
if(m>=50)
cout<<"五十元硬幣"<<m/50<<"枚"<<endl;
m=m%50;
if(m>=10)
cout<<"十元硬幣"<<m/10<<"枚"<<endl;
m=m%10;
if(m>=1)
cout<<"一元硬幣"<<m/1<<"枚"<<endl;
m=m%1;
}
system("pause");
return 0;
}
複製代碼
作者:
王競儀
時間:
2022-4-16 17:15
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int price=0,cost=0,money=0;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"客人付了多少錢: ";
cin>>cost;
cout<<endl;
if(price==cost)
{
cout<<"剛剛好! 銘謝惠顧!"<<endl;
}
else if(price>cost)
{
cout<<"錢不夠喔! 還差"<<price-cost<<"元"<<endl;
}
else if(cost>10000)
{
cout<<"錢太多? 全部送我吧!"<<endl;
}
else
{
money=cost-price;
cout<<"需找客人"<<money<<"元"<<endl;
cout<<endl;
if(money>=1000)
{
cout<<"一千元鈔票"<<money/1000<<"張"<<endl;
money=money%1000;
}
if(money>=500)
{
cout<<"五百元鈔票"<<money/500<<"張"<<endl;
money=money%500;
}
if(money>=100)
{
cout<<"一百元鈔票"<<money/100<<"張"<<endl;
money=money%100;
}
if(money>=50)
{
cout<<"五十元硬幣"<<money/50<<"枚"<<endl;
money=money%50;
}
if(money>=10)
{
cout<<"十元硬幣"<<money/10<<"枚"<<endl;
money=money%10;
}
if(money>=5)
{
cout<<"五元硬幣"<<money/5<<"枚"<<endl;
money=money%5;
}
if(money>=1)
{
cout<<"一元硬幣"<<money<<"枚"<<endl;
}
}
system("pause");
goto re;
return 0;
}
複製代碼
作者:
侯宣仲
時間:
2022-4-16 17:20
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int price,pay,money;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"客人付了多少錢: ";
cin>>pay;
money=pay-price;
if(price==pay)
cout<<"剛剛好 , 銘謝惠顧";
else if(pay<price){
cout<<"不夠多喔!還差"<<price-pay<<"元!";
else if(pay>price){
cout<<"錢太多?送我吧!";
else if{
cout<<endl<<"需找客人"<<money<<"元"<<endl<<endl;
if(money>=500)
{
cout<<"五百元鈔票"<<money/500<<"張"<<endl;
money%=500;
}
if(money>=100)
{
cout<<"一百元鈔票"<<money/100<<"張"<<endl;
money%=100;
}
if(money>=50)
{
cout<<"五十元硬幣"<<money/50<<"枚"<<endl;
money%=50;
}
if(money>=10)
{
cout<<"十元硬幣"<<money/10<<"枚"<<endl;
money%=10;
}
if(money>=5)
{
cout<<"五元硬幣"<<money/5<<"枚"<<endl;
money%=5;
}
if(money>0)
cout<<"一元硬幣"<<money<<"枚"<<endl;
}
cout<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
李彥錡
時間:
2022-4-16 17:20
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int price=0,cost=0,money=0;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"客人付了多少錢: ";
cin>>cost;
cout<<endl;
money=cost-price;
cout<<"需找客人: "<<money<<"元"<<endl<<endl;
if(money==cost)
cout<<"剛剛好! 銘謝惠顧!";
else if(money<cost)
cout<<"錢不夠! 還差"<<money-cost<<"元";
else if(money<10000)
cout<<"錢太多! 全部送我吧!";
else{
if(money>=500){
cout<<"五百元鈔票"<<money/500<<"張"<<endl;
money=money%500;
}
if(money>=100){
cout<<"一百元鈔票"<<money/100<<"張"<<endl;
money=money%100;
}
if(money>=50){
cout<<"五十元鈔票"<<money/50<<"枚"<<endl;
money=money%50;
}
if(money>=10){
cout<<"十元硬幣"<<money/10<<"枚"<<endl;
money=money%10;
}
if(money>=5){
cout<<"五元硬幣"<<money/5<<"枚"<<endl;
money=money%5;
}
if(money>=1){
cout<<"一元硬幣"<<money/1<<"枚"<<endl;
money=money%1;
}
}
system("pause");
return 0;
}
複製代碼
作者:
孫文康
時間:
2022-4-16 17:28
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int price,pay,money;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"客人付了多少錢: ";
cin>>pay;
money=pay-price;
if(pay==price)
{
cout<<"剛剛好!銘謝惠顧";
}
else if(price>pay)
cout<<"錢不夠哦!還"<<(price-pay)<<"元";
else if(pay>10000)
cout<<"錢太多?全部送我吧";
else{
cout<<endl<<"需找客人"<<money<<"元"<<endl<<endl;
if(money>=500)
{
cout<<"五百元鈔票"<<money/500<<"張"<<endl;
money%=500; //money=money%500;
}
if(money>=100)
{
cout<<"一百元鈔票"<<money/100<<"張"<<endl;
money%=100;
}
if(money>=50)
{
cout<<"五十元硬幣"<<money/50<<"枚"<<endl;
money%=50;
}
if(money>=10)
{
cout<<"十元硬幣"<<money/10<<"枚"<<endl;
money%=10;
}
if(money>=5)
{
cout<<"五元硬幣"<<money/5<<"枚"<<endl;
money%=5;
}
if(money>0)
cout<<"一元硬幣"<<money<<"枚"<<endl;
}
system("pause");
goto re;
return 0;
}
複製代碼
作者:
石皓云
時間:
2022-4-16 17:37
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
int a,b,c;
cout<<"***智慧找零系統***"<<endl<<endl;
cout<<"請輸入商品價格:";
cin>>a;
cout<<"客人付了多少錢:";
cin>>b;
cout<<endl;
c=b-a;
if(b==a){
cout<<"剛剛好!不用找!"<<endl;
}
else if(b<a)
cout<<"錢不夠!還差"<<"元"
else if(a>10000)
cout<<"錢太多"
else
cout<<"需找客人"<<c<<"元"<<endl;
if(c>=500){
cout<<"五百元鈔票"<<c/500<<"張"<<endl;
c %= 500;
}
if(c>=100){
cout<<"一百元鈔票"<<c/100<<"張"<<endl;
c %= 100;
}
if(c>=50) {
cout<<"五十元硬幣"<<c/50<<"枚"<<endl;
c %= 50;
}
if(c>=10){
cout<<"十元硬幣"<<c/10<<"枚"<<endl;
c %= 10;
}
if(c>=1)
cout<<"一元硬幣"<<c<<"枚"<<endl;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
許博鈞
時間:
2022-4-23 15:32
#include<iostream>
#include<cstdlib>
using namespace std;
int main() //:D
{
re:
system("cls");
int price,pay,money;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"客人付了多少錢: ";
cin>>pay;
money=pay-price;
if(pay>price)
{
cout<<endl<<"需找客人"<<money<<"元"<<endl<<endl;
if(money>=500)
{
cout<<"五百元鈔票"<<money/500<<"張"<<endl;
money%=500; //money=money%500;
}
if(money>=100)
{
cout<<"一百元鈔票"<<money/100<<"張"<<endl;
money%=100;
}
if(money>=50)
{
cout<<"五十元硬幣"<<money/50<<"枚"<<endl;
money%=50;
}
if(money>=10)
{
cout<<"十元硬幣"<<money/10<<"枚"<<endl;
money%=10;
}
if(money>=5)
{
cout<<"五元硬幣"<<money/5<<"枚"<<endl;
money%=5;
}
if(money>0)
cout<<"一元硬幣"<<money<<"枚"<<endl;
cout<<endl;
}
if(price>pay)
cout<<"錢不夠喔!還差"<<price-pay<<"元"<<endl;
cout<<endl;
if(price==pay)
cout<<"剛剛好!謝謝惠顧"<<endl;
cout<<endl;
if(money>10000)
cout<<"錢太多?全部送我吧"<<endl;
cout<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
侯宥安
時間:
2022-4-23 15:33
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int price,pay,money;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
if(price<=0)
goto re;
cout<<"客人付了多少錢: ";
cin>>pay;
if(pay<0)
goto re;
money=pay-price;
if(money==0)
{
cout<<endl<<"剛剛好!銘謝惠顧!"<<endl;
}else if(money<0)
{
cout<<endl<<"錢不夠喔!還差"<<-money<<"元!"<<endl;
}else if(money>=1000)
{
cout<<endl<<"錢太多?全部送我吧!"<<endl;
}else
{
cout<<endl<<"需找客人"<<money<<"元"<<endl<<endl;
if(money>=500)
{
cout<<"五百元鈔票"<<money/500<<"張"<<endl;
money%=500; //money=money%500;
}
if(money>=100)
{
cout<<"一百元鈔票"<<money/100<<"張"<<endl;
money%=100;
}
if(money>=50)
{
cout<<"五十元硬幣"<<money/50<<"枚"<<endl;
money%=50;
}
if(money>=10)
{
cout<<"十元硬幣"<<money/10<<"枚"<<endl;
money%=10;
}
if(money>=5)
{
cout<<"五元硬幣"<<money/5<<"枚"<<endl;
money%=5;
}
if(money>0)
cout<<"一元硬幣"<<money<<"枚"<<endl;
}
cout<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
錢冠叡
時間:
2022-4-23 15:44
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int price,pay,money;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"客人付了多少錢: ";
cin>>pay;
money=pay-price;
if(pay>price)
{
cout<<endl<<"需找客人"<<money<<"元"<<endl<<endl;
if(money>=500)
{
cout<<"五百元鈔票"<<money/500<<"張"<<endl;
money%=500; //money=money%500;
}
if(money>=100)
{
cout<<"一百元鈔票"<<money/100<<"張"<<endl;
money%=100;
}
if(money>=50)
{
cout<<"五十元硬幣"<<money/50<<"枚"<<endl;
money%=50;
}
if(money>=10)
{
cout<<"十元硬幣"<<money/10<<"枚"<<endl;
money%=10;
}
if(money>=5)
{
cout<<"五元硬幣"<<money/5<<"枚"<<endl;
money%=5;
}
if(money>0)
cout<<"一元硬幣"<<money<<"枚"<<endl;
cout<<endl;
}
if(price>pay)
cout<<"錢不夠喔!還差"<<price-pay<<"元"<<endl;
cout<<endl;
if(price==pay)
cout<<"剛剛好!謝謝惠顧"<<endl;
cout<<endl;
if(money>10000)
cout<<"錢太多?全部送我吧"<<endl;
cout<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2