📄 random.cpp
字号:
// Random.cpp: implementation of the CRandom class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "RTDMOEA.h"
#include "Random.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
int CRandom::Seed=0;
CRandom::CRandom()
{
RandomInit();
}
CRandom::~CRandom()
{
}
void CRandom::RandomInit()
{
Seed= (int)time(NULL);
RandomInit(Seed);
}
void CRandom::RandomInit(int seed)
{
Seed=seed;
srand(Seed);
}
double CRandom::Random(double m_Start, double m_End)
{
return m_Start + (m_End - m_Start) * rand() /RAND_MAX;
}
int CRandom::Random(int m_Start, int m_End) //[m_Start , m_End]
{
return (m_Start + rand() % (m_End -m_Start+1));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -