난수1 난수와 std::map을 사용한 랜덤 이벤트 시간 생성 예제 아래 코드는 std::map을 사용하여 200개의 랜덤한 시간 간격을 가지는 "dummy" 문자열을 저장 합니다. #include #include #include #include #include typedef int64_t Time; typedef std::map TimeMap; const int num_entries = 200; Time random_time(Time start, Time end) { std::random_device rd; std::mt19937 gen(rd()); std::uniform_int_distribution dist(start, end / num_entries); // 2 return dist(gen); } void populate_map(Time start, Time en.. 2023. 7. 17. 이전 1 다음