- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main()
- {
- int a, b, c;
- int money1, money, choice;
- cout<<"$$$ 歡迎使用吃角子老虎虛擬遊戲機 $$$"<<endl;
- cout<<"遊戲規則說明:"<<endl;
- cout<<"玩一次10元"<<endl;
- cout<<"任一欄出現7 --> 獎金變兩倍"<<endl;
- cout<<"任兩欄出現7 --> 獎金變十倍"<<endl;
- cout<<"三欄都出現7 --> 獎金變一百倍"<<endl;
- cout<<"請投幣: ";
- cin>>money1;
- money=money1;
- start:
- srand(time(NULL));
- a=rand()%10;
- b=rand()%10;
- c=rand()%10;
- cout<<"轉啊轉..."<<endl;
- cout<<a<<" "<<b<<" "<<c<<endl;
- if(a==7 && b==7 && c==7)
- {
- cout<<"哇!!! 第一特獎!!!"<<endl;
- cout<<"你贏了1000元!"<<endl;
- money=money+1000;
- }
- else if((a==7 && b==7 && c!=7)||(a==7 && b!=7 && c==7)||(a!=7 && b==7 && c==7))
- {
- cout<<"恭喜你! 中了二獎!"<<endl;
- cout<<"你贏了100元!"<<endl;
- money=money+100;
- }
- else if((a==7 && b!=7 && c!=7)||(a!=7 && b==7 && c!=7)||(a!=7 && b!=7 && c==7))
- {
- cout<<"恭喜你! 中了三獎!"<<endl;
- cout<<"雖然只贏了10元, 還是很棒喔!"<<endl;
- money=money+10;
- }else
- {
- cout<<"哎呀! 損失了10元!"<<endl;
- money=money-10;
- if(money==0)
- {
- cout<<"你怎麼把錢輸光了! 一毛不剩!"<<endl;
- cout<<"強制驅離!"<<endl;
- goto end;
- }
- }
- cout<<"目前餘額: "<<money<<"元"<<endl;
- cout<<"1-再玩一把 2-見好就收"<<endl;
- cin>>choice;
- if(choice==1)
- {
- goto start;
- }else
- {
- goto end;
- }
- end:
- if(money-money1>0)
- {
- cout<<"太好囉! 你今天共贏了"<<money-money1<<"元!"<<endl;
- }else if(money-money1<0)
- {
- cout<<"太遺憾了! 你今天共輸掉了"<<money1-money<<"元!"<<endl;
- }else
- {
- cout<<"沒輸沒贏, 全身而退!"<<endl;
- }
- system("pause");
- return 0;
- }
複製代碼 |