- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main()
- {
- int a, b, c;
- int run=0;
- cout<<"$$$ 吃角子老虎機中獎機率評估程式 $$$"<<endl;
- cout<<"中獎規則說明:"<<endl;
- cout<<"任一欄出現3 --> 獎金變兩倍"<<endl;
- cout<<"任兩欄出現3 --> 獎金變十倍"<<endl;
- cout<<"三欄都出現3 --> 獎金變一百倍"<<endl;
- cout<<"本次測試方式: 測試看看大約要跑幾次才能拉中三獎任一欄出現3"<<endl;
- system("pause");
- srand(time(NULL));
- while(true)
- {
- run++;
- a=rand()%10;
- b=rand()%10;
- c=rand()%10;
- cout<<a<<" "<<b<<" "<<c<<endl;
- if((a==3 && b!=3 && c!=3)||(a!=3 && b==3 && c!=3)||(a!=3 && b!=3 && c==3))
- {
- break;
- }
- }
- cout<<"共計"<<run<<"次!"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |