本帖最後由 黃博鴻 於 2012-10-1 21:43 編輯
- #include<iostream>
- using namespace std;
- int main()
- {
- int times=0;
- int a, b, c;
- double money, omoney, bet;
- int choice;
- cout<<"***歡迎使用吃角子老虎機 V1.0***"<<endl;
- cout<<"遊戲規則如下:"<<endl
- <<"中三獎, 任一欄出現7 --> 贏得下注金兩倍的獎金"<<endl
- <<"中二獎, 任兩欄出現7 --> 贏得下注金十倍的獎金"<<endl
- <<"中第一特獎, 三欄都出現7 --> 贏得下注金一百倍的獎金"<<endl<<endl;
- begin:
- cout<<"請輸入你所帶的錢: ";
- cin>>money;
- omoney=money;
- if(money==0)
- {
- cout<<"你是不是想玩免費的啊?"<<endl;
- goto begin;
- }else if(money>100000)
- {
- cout<<"你是不是錢太多啊?"<<endl;
- goto begin;
- }
- start:
- cout<<"請輸入下注金額: ";
- cin>>bet;
- if(bet>money)
- {
- cout<<"你是不是頭殼壞掉了?"<<endl;
- goto start;
- }
- times++;
- srand(time(NULL));
- system("cls");
- for(int i=1; i<=50; i++)
- {
- a=rand()%10;
- b=rand()%10;
- c=rand()%10;
- cout<<a<<" "<<b<<" "<<c<<" 我轉我轉我轉轉轉!"<<endl;
- system("cls");
- }
- cout<<a<<" "<<b<<" "<<c<<" 噹噹!"<<endl<<endl;
- if((a==7 && b!=7 && c!=7)||(a!=7 && b==7 && c!=7)||(a!=7 && b!=7 && c==7))
- {
- cout<<"恭喜你,中了三獎!";
- money=money+bet*2;
- cout<<"你獲得獎金"<<bet*2<<"元, 所剩餘額為"<<money<<"元"<<endl;
- }else if((a==7 && b==7 && c!=7)||(a!=7 && b==7 && c==7)||(a==7 && b!=7 && c==7))
- {
- cout<<"恭喜你,中了二獎!";
- money=money+bet*10;
- cout<<"你獲得獎金"<<bet*10<<"元, 所剩餘額為"<<money<<"元"<<endl;
- }else if(a==7 && b==7 && c==7)
- {
- cout<<"恭喜你,中了第一特獎!";
- money=money+bet*100;
- cout<<"你獲得獎金"<<bet*100<<"元, 所剩餘額為"<<money<<"元"<<endl;
- }
- else
- {
- money=money-bet;
- if(money==0)
- {
- cout<<"哎呀! 你怎麼把錢輸光了!"<<endl;
- cout<<"強制驅離!"<<endl;
- goto end;
- }
- cout<<"沒中!"<<endl;
- cout<<"損失"<<bet<<"元, 所剩餘額"<<money<<"元!"<<endl;
- }
- cout<<endl;
- choose:
- cout<<"1-再搏一回 2-見好就收"<<endl;
- cout<<"請選擇"<<endl;
- cin>>choice;
- if(choice==1)
- {
- goto start;
- }else if(choice==2)
- {
- goto end;
- }else
- {
- cout<<"代碼錯誤"<<endl;
- goto choose;
- }
- end:
- cout<<"***戰績***"<<endl;
- cout<<"總共搏了"<<times<<"回, ";
- if(omoney<money)
- {
- cout<<"贏了"<<money-omoney<<"元"<<endl;
- }
- else if(omoney>money)
- {
- cout<<"輸了"<<omoney-money<<"元"<<endl;
- }else
- {
- cout<<"沒輸沒贏, 全身而退"<<endl;
- }
-
- system("pause");
- return 0;
- }
複製代碼 |