- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main()
- {
- int a,b,c;
- int money;
- int choice;
- cout<<"$$$ 吃角子老虎機中獎機率評估程式 $$$"<<endl;
- cout<<"中獎規則說明:"<<endl;
- cout<<"任一欄出現7 --> 獎金變兩倍"<<endl;
- cout<<"任兩欄出現7 --> 獎金變十倍"<<endl;
- cout<<"三欄都出現7 --> 獎金變一百倍"<<endl;
- cout<<"請投幣: ";
- cin>>money;
- 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 ;
- }
- 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 ;
- }
- 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<<"恭喜你沒中獎"<<endl;
- cout<<"獲得-10元"<<endl;
- money=money-10;
- }
- cout<<"目前餘額:"<<money<<"元"<<endl;
- cout<<"1:再玩一把 2:見好就收"<<endl;
- cin>>choice;
- if(choice==1)
- {
- goto start;
- } else
- {
- goto end;
- }
- end:
- system("pause");
- return 0;
- }
複製代碼 |