本帖最後由 t8155745 於 2012-2-18 16:13 編輯
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main()
- {
- int a,b,c,run=0;
- cout<<"$$$吃角子老好機中獎機率評估程式$$$"<<endl;
- cout<<"中獎規則說明:"<<endl;
- cout<<"任一欄出現7獎金兩倍"<<endl;
- cout<<"任兩欄出現7獎金十倍"<<endl;
- cout<<"三欄出現7獎金一百倍"<<endl;
- cout<<"本次測驗方式:試試看大約要跑幾次才能拉中第二特獎,兩欄出現7"<<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==7 && b==7 && c!=7)||(a!=7 && b==7 && c==7)||(c==7 && a==7 && b!=7) )
- {
- break;
- }
-
- }
- cout<<"共"<<run<< "次";
- system("pause");
- return 0;
- }
複製代碼 |