- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- allre:
- system("cls");
- int thing[5]={100,500,1000,5000,10000};
- int dollers1;
- int dollers2;
- srand(time(NULL));
- cout<<"***抽獎大會***"<<endl;
- cout<<"第1次抽獎你抽中什麼呢?"<<endl<<endl;
- system("pause");
- system("cls");
- for(int i=0;i<=150;i++)
- {
- dollers1=rand()%5;
- if(i%2==0)
- cout<<"***抽獎中...***"<<endl;
- else
- cout<<"*******抽獎中...*******"<<endl;
- cout<<thing[dollers1]<<"元"<<endl;
- system("cls");
- }
- cout<<"你抽中:"<<thing[dollers1]<<"元"<<"!"<<endl<<endl;
- cout<<"第2次抽獎你抽中什麼呢?"<<endl<<endl;
- system("pause");
- system("cls");
- for(int i=0;i<=150;i++)
- {
- dollers2=rand()%5;
- if(i%2==0)
- cout<<"***抽獎中...***"<<endl;
- else
- cout<<"*******抽獎中...*******"<<endl;
- cout<<thing[dollers2]<<"元"<<endl;
- system("cls");
- }
- cout<<"你抽中:"<<thing[dollers2]<<"元"<<"!"<<endl<<endl;
- int have;
- int shop;
- int player1;
- cout<<"<1>要 <2>不要"<<endl;
- cin>>have;
- if(have==1)
- {
- cout<<"恭喜你得到"<<thing[dollers1]+thing[dollers2]<<"元"<<"!"<<endl;
- cout<<"請問您要去購物中心購買商品嗎?"<<endl;
- cout<<"<1>要 <2>不要"<<endl;
- cin>>shop;
- if(shop==1)
- {
- reset:
- system("cls");
- int p,pay=0,popo,money,opt,sum=0;
- string name[5]={"砍頭優惠卷","特效搖頭丸","自殺體驗卷","被打免費票","舒柔鼻涕蟲",};
- int price[5]={200,500,5000,10000,10500};
- cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
- cout<<"[商品價目表]"<<endl;
- int qty[5]={0,0,0,0,0};
- cout<<"你可以消費"<<thing[dollers1]+thing[dollers2]<<"元"<<"!"<<endl;
- for(int i=0; i<5; i++)
- {
- cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
- }
- cout<<"(8)結帳"<<endl<<endl;
- re:
- cout<<"請輸入商品代碼: ";
- cin>>p;
- if(p==8)
- goto checkout;
- else if(p>=1 && p<=7)
- {
- cout<<"數量: ";
- cin>>popo;
- if(popo<=0)
- {
- cout<<"輸入錯誤!"<<endl;
- goto re;
- }
- sum+=price[p-1]*popo;
- qty[p-1]+=popo;
- }
- else
- {
- cout<<"輸入錯誤!"<<endl;
- }
- goto re;
- checkout:
- cout<<endl<<"噁心清單"<<endl;
- cout<<"----------------------------------"<<endl;
- for (int i=0;i<5;i++)
- {
- if(qty[i]!=0)
- cout<<name[i]<<"\t"<<price[i]<<"元 * "<<qty[i]<<"個"<<endl;
- }
- cout<<"----------------------------------"<<endl;
- cout<<"總共"<<sum<<"元!"<<endl<<endl;
- cout<<"1-正確無誤"<<endl<<"2-重新選購"<<endl;
- cin>>opt;
- if(opt==1)
- {
- goto change;
- }
- if(opt==2)
- {
- goto reset;
- }
- change:
- /*
- cout<<"請付錢:";
- cin>>pay;
-
- if(pay<=0)
- {
- cout<<endl<<"你是誰啊?!"<<endl<<endl;
- goto change;
- }
- */
- if(sum>thing[dollers1]+thing[dollers2])
- {
- cout<<"騙人!!你明明只得到"<<thing[dollers1]+thing[dollers2]<<"元"<<"!"<<endl;
- goto reset;
- }
- money=thing[dollers1]+thing[dollers2]-sum;
- if(money==0)
- {
- cout<<endl<<"剛剛好! 銘謝惠顧!"<<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>=1)
- {
- cout<<"一元硬幣"<<money<<"枚"<<endl;
- }
-
- cout<<endl;
- }
- }
- if(shop==2)
- {
- cout<<"還有剪刀石頭布的遊戲您要玩嗎?"<<endl;
- cout<<"(1)我要去玩 (2)謝謝!下次再來玩"<<endl;
- cin>>player1;
- if(player1==1)
- {
- goto pp;
- }
- if(player1==2)
- {
- goto allre;
- }
- }
- }
- if(have==2)
- {
- cout<<"你拒絕了嗎?有機會再來唷!!"<<endl;
- system("pause");
- goto allre;
- }
- srand(time(NULL));
- pp:
- system("cls");
- int g, c, sum2=0, lose=0, same=0;
- alllre:
- string name[5]={"改去購物中心","退出遊戲","剪刀","石頭","布"};
- cout<<"請選擇! <1>改去購物中心 <2>退出遊戲 <3>剪刀 <4>石頭 <5>布 <6>戰績歸零 <7>觀看結果 ";
- cin>>g;
- if(g==7)
- goto result;
- else if(g==6)
- goto pp;
- else if(g==1)
- goto reset;
- else if(g==2)
- goto allre;
- else
- {
- cout<<"你出"<<name[g-1]<<"!"<<endl;
- c=rand()%3+3;
- cout<<"電腦出"<<name[c-1]<<"!"<<endl;
- if(g-c==1)
- {
- cout<<"你贏了!!"<<endl;
- sum2+=1;
- }
- else if(g-c==-2)
- {
- cout<<"你贏了!!"<<endl;
- sum2+=1;
- }
- else if(c==g)
- {
- cout<<"平手!!"<<endl;
- same+=1;
- }
-
- else
- {
- cout<<"你輸了!!"<<endl;
- lose+=1;
- }
- system("pause");
- goto pp;
- }
- result:
- cout<<"***戰果統計***"<<endl;
- cout<<"總共贏了"<<sum2<<"次"<<endl;
- cout<<"總共平手"<<same<<"次"<<endl;
- cout<<"總共輸了"<<lose<<"次"<<endl;
- system("pause");
- goto pp;
- return 0;
- }
複製代碼 |