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