boost生成随机数

/*输入参数:随机数位数*/
/*输出参数:随机数*/
boost::mt19937 m_oBoostRandomSeed_;
GetRandomNumber(int nDigits)
{
	double dRangeMin = pow((double)10,nDigits);
	double dRangeMax = pow((double)10,nDigits+1) -1 ;	
	boost::uniform_int<> range(static_cast<int>(dRangeMin),static_cast<int>(dRangeMax));
	boost::variate_generator<boost::mt19937&,boost::uniform_int<> > genRandom(m_oBoostRandomSeed_,range);
	return genRandom();
}


生成器列表见:
http://www.boost.org/doc/libs/1_46_1/doc/html/boost_random/reference.html#boost_random.reference.generators






你可能感兴趣的:(boost)