返回列表 發帖
  1. #include<iostream>   
  2. #include<cstdlib>   
  3. #include<ctime>      
  4. using namespace std;
  5. int main()
  6. {
  7.     int a,b,c;
  8.     int run=0;
  9.     cout<<"$$$ 吃角子老虎機中獎機率評估程式 $$$"<<endl;
  10.     cout<<"中獎規則說明:"<<endl;
  11.     cout<<"任一欄出現 7-->您投下的賭注成兩倍"<<endl;
  12.     cout<<"任兩欄出現 7-->您投下的賭注成十"<<endl;
  13.     cout<<"三欄現 7-->您投下的賭注成一百"<<endl;
  14.     cout<<"本次測試方式:式大約要跑幾次才能拉中第一獎"<<endl;
  15.     system("pause");
  16.     srand(time(NULL));
  17.     while(true)
  18.     {
  19.                run++;
  20.                a=rand()%10;
  21.                b=rand()%10;
  22.                c=rand()%10;
  23.                cout<<a<<" "<<b<<" "<<c<<endl;
  24.                if(a==7 && b==7 && c==7)
  25.                {
  26.                        break;
  27.                }
  28.     }
  29.     cout<<"共有"<<run<<"次"<<endl;
  30.     system("pause");
  31.     return 0;   
  32. }
複製代碼

TOP

返回列表