- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main()
- {
- int a, b, c;
- int run=0 ;
- cout<<"$$$吃角子老虎機評估中獎機率程式$$$"<<endl;
- cout<<"~中獎規則說明~"<<endl;
- cout<<"任一欄出現一個7--> 獎金2倍 "<<endl;
- cout<<"任兩欄出現兩個7--> 獎金10倍 "<<endl;
- cout<<"三欄都出現7--> 獎金100倍 "<<endl;
- cout<<"本次測試 試試看要轉幾次才會轉到第三特獎 "<<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) || (a!=7 && b!=7 && c==7))
- {
- break;
- }
- }
- cout<<"共計"<<run<<"次"<<endl;
-
-
- system("pause");
- return 0;
- }
複製代碼 |