标签:
研究过随机数吗?我们都知道电脑里面的随机数其实只是看上去是随机的,产生的过程都是确定的。如果我们有一定的破解能力,我们就能预测得到,下一次机器产生的随机数是哪个值。#include<iostream>
#include<ctime>
#include <cstdlib>
using namespace std;
int main()
{
srand(time(0));//time(0)返回当前时间传到srand里面做随机种子
int x=rand();
}float x1,x2,w,y1,y2;
do
{
x1=2.0*randf()-1.0;
x2=2.0*randf()-1.0;
w=x1*x1+x2*x2;
}while(w>=1.0);
w=sqrt((-2.0*log(w))/w);
y1=x1*w;
y2=x2*w;标签:
原文地址:http://blog.csdn.net/bleuesprit/article/details/45286513