[C++] 랜덤 함수 C++11 표준에서 제공하는 랜덤 엔진 메르센 트위스터 는 rand() 함수보다 빠르며, 분포도가 고르며 전역성을 띄지 않습니다. 때문에 rand() 함수를 이제 아래와같이 mt199937 클래스로 대체하여 사용합니다. int getRandom(int min, int max) { std::random_device rd; std::mt19937 rEngine(rd()); std::uniform_int_distribution dist(min, max); return static_cast(dist(rEngine)); } float getRandom(float min, float max) { std::random_device rd; std::mt19937 rEngine(rd()); std::uniform_rea.. 더보기 이전 1 ··· 5 6 7 8 9 10 11 ··· 44 다음