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

  30. system("pause");   
  31. return 0;   
  32. }
複製代碼

TOP

返回列表