赌场有一种游戏,称为“幸运7”,游戏规则是丢两个骰子,如果其点数之和为7你就赢4元,不是7你就输1元。请分析一下,这样的规则是否公平呢?在模拟过程中,我们让计算机循环执行100000次。这个循环应该怎么写
#include <time.h>
#include <iostream>
using namespace std;
int main()
{
srand((unsigned)time(NULL));
int n = 0;
for(int i=0;i<100000;i++)
{
int s1 = rand()%6+1;
int s2 = rand()%6+1;
if(s1+s2 == 7)
n+=4;
else
n-=1;
}
cout<<"最终获得:"<<n<<"元"<<endl;
system("pause");
return 0;
}
大概要输1万多,肯定是不公平的