- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int a, b ,c;
- float run=1,three=0;
- int rate;
- cout<<"$$$ 吃角子老虎機中獎機率評估程式 $$$"<<endl;
- cout<<"中獎規則說明:"<<endl;
- cout<<"任一欄出現 7-->您投下的賭注成兩倍"<<endl;
- cout<<"任兩欄出現 7-->您投下的賭注成十"<<endl;
- cout<<"三欄現 7-->您投下的賭注成一百"<<endl;
- cout<<"本次測試方式:測試100次中三獎的機率"<<endl;
- while(run<=100)
- {
- run++;
- a=rand()%10;
- b=rand()%10;
- c=rand()%10;
- cout<<a<<" "<<b<<" "<<c<<endl;
- if((a==7 && b!=7 && c!=7)||(a!=7 && b==7 && c!=7)||(a!=7 && b!=7 && c==7))
- {
- three++;
- }
- run++;
- }
- rate=three/run*100;
- cout<<"在這一百次中您的中獎機率是"<<rate<<"%"<<endl;
-
- system("pause");
- return 0;
- }
複製代碼 |