?? 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 + -