- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- re2:
- int p,q,sum=0,option,pay,money;
- string name[7]={"速效跳課糖","米你毛毛球","無頭帽","金斯雀奶油蛋糕","攜帶型沼澤","假魔杖","伸縮耳"};
- int price[7]={90,80,74,3,80,1,4};
- int qty[7]={0,0,0,0,0,0,0};
- cout<<"****衛氏巫師法寶店****"<<endl<<endl;
- cout<<"[商品價目表]"<<endl;
- for(int i=0; i<7; i++)
- {
- cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
- }
- cout<<"(8)結帳"<<endl<<endl;
- cout<<"[加隆任務]消費100加隆送假魔丈*30"
- re:
- cout<<"請輸入商品代碼: ";
- cin>>p;
- if(p==8)
- goto checkout;
- else if(p>=1 && p<=7)
- {
- cout<<"數量: ";
- cin>>q;
- if(q<=0)
- {
- cout<<"錯誤!"<<endl;
- goto re;
- }
- sum+=price[p-1]*q;
- qty[p-1]+=q;
- }
- else
- {
- cout<<"錯誤!"<<endl;
- }
- goto re;
- checkout:
- cout<<endl<<"[魔法清單]"<<endl;
- cout<<"-----------------------------"<<endl;
- for(int i=0; i<7; i++)
- {
- if(qty[i]!=0)
- cout<<name[i]<<"\t"<<price[i]<<"加隆 * "<<qty[i]<<"個"<<endl;
- }
- cout<<"-----------------------------"<<endl;
- if(sum >= 100)
- {
- cout<<"你消費"<<sum<<"加隆,符合滿100加隆的任務"<<endl<<endl;
- cout<<"假魔丈*30是你的了!"<<endl;
- }
- cout<<"總共"<<sum<<"加隆!"<<endl<<endl;
- cout<<"1-正確無誤 2-重新選購 ";
- cin>>option;
- if(option==1)
- {
- goto change;
- }
- else
- {
- system("cls");
- goto re2;
- }
- change:
- cout<<endl<<"請付帳: ";
- cin>>pay;
- money=pay-sum;
- if(money==0)
- {
- cout<<"感謝光臨!"<<endl;
- }
- else if(money<0)
- {
- cout<<"快把"<<-money<<"加隆交來!"<<endl;
- goto change;
- }else
- {
- cout<<"找你"<<money<<"加隆"<<endl;
- if(money>=100)
- {
- cout<<"100加隆"<<money/100<<"枚"<<endl;
- money%=100;
- }
- if(money>=50)
- {
- cout<<"50加隆"<<money/50<<"枚"<<endl;
- money%=50;
- }
- if(money>=10)
- {
- cout<<"10加隆"<<money/10<<"枚"<<endl;
- money%=10;
- }
- if(money>0)
- {
- cout<<"1加隆"<<money<<"枚"<<endl;
- }
- }
- cout<<endl<<"下次再來"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |