標題:
吃角子老虎機 - 中獎機率評估 (一)
[打印本頁]
作者:
tonyh
時間:
2012-2-11 16:21
標題:
吃角子老虎機 - 中獎機率評估 (一)
本帖最後由 tonyh 於 2012-2-11 17:34 編輯
我們將開發一個三個欄位的吃角子老虎機遊戲程式,
其中獎規則如下:
任一欄出現7 --> 獎金變兩倍
任兩欄出現7 --> 獎金變十倍
三欄都出現7 --> 獎金變一百倍
本次評估方式說明:
測試看看大約要跑幾次才能拉中第一特獎777
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
int a, b, c;
int run=0;
cout<<"$$$ 吃角子老虎機中獎機率評估程式 $$$"<<endl;
cout<<"中獎規則說明:"<<endl;
cout<<"任一欄出現7 --> 獎金變兩倍"<<endl;
cout<<"任兩欄出現7 --> 獎金變十倍"<<endl;
cout<<"三欄都出現7 --> 獎金變一百倍"<<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<<"共計"<<run<<"次!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
t3742238
時間:
2012-2-11 17:35
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int a,b,c;
int run=0;
cout<<"$$$ 吃角子老虎機中獎機率評估程式 $$$"<<endl;
cout<<"中獎規則說明:"<<endl;
cout<<"任一欄出現 7-->您投下的賭注成兩倍"<<endl;
cout<<"任兩欄出現 7-->您投下的賭注成十"<<endl;
cout<<"三欄現 7-->您投下的賭注成一百"<<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)
{
break;
}
}
cout<<"共有"<<run<<"次"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
劉漢文
時間:
2012-2-11 17:35
#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<<"本次測試 試試看要轉幾次才會轉到第一特獎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<<"共計"<<run<<"次"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
尤泓鈞
時間:
2012-2-11 17:35
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
int run=0;
cout<<"$$$支票回收機$$$"<<endl;
cout<<"遊戲規則說明:"<<endl;
cout<<"凡是任一欄出現7,獎金雙倍"<<endl;
cout<<"凡是任兩欄出現7,獎金十倍"<<endl;
cout<<"凡是任三欄都出現7,獎金一百倍"<<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)
{
break;
}
}
cout<<"共計"<<run<<"次"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
t2364705
時間:
2012-2-11 17:36
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int a, b, c, run=0;
cout<<"$$$$吃錢老虎機中獎機率評估程式$$$$"<<endl;
cout<<"中獎規則說明: "<<endl;
cout<<"出現一個3 --> 獎金變四倍"<<endl;
cout<<"出現兩個3 --> 獎金變十倍"<<endl;
cout<<"三個3都出現 --> 獎金一百倍"<<endl;
cout<<"本次測試: 試試看要拉幾次才會拉中大獎: 333"<<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==3 && b==3 && c==3)
{
break;
}
}
cout<<"共計: "<<run<<" 次!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
許逸瑋
時間:
2012-2-11 17:39
本帖最後由 許逸瑋 於 2012-2-11 18:11 編輯
#include<iostream> //當用到標準輸入與輸出時,需插入此標題檔
#include<cstdlib> //當用到亂數函數時,需插入此標題檔
#include<ctime> //當用到時間函數時,需插入此標題檔
using namespace std;
int main()
{
int a, b, c;
int run=0;
cout<<"~~~Money!!! come and go@@~~~"<<endl;
cout<<"There are the prise description below-3-"<<endl;
cout<<"if one 7 shows up~"<<"money X2!!"<<endl;
cout<<"if two 7 shows up~~"<<"money X10!!!"<<endl;
cout<<"if three 7 shows up~~~"<<"money X100!!!!"<<endl;
cout<<"this test is going to count how much times does it take to get 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<<"it runs"<<run<<"times"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
t8155745
時間:
2012-2-11 17:40
#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<<"本次測驗方式:試試看大約要跑幾次才能拉中第一特獎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<<"共"<<run<< "次";
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2